09-26-2013 04:34 AM - edited 09-26-2013 04:34 AM
I have 4 different situatons as shown in attachment. The points for black lines are obtained from edge detection. Two lines(black) intersect each other at a point (red). Green one is the bisecting line. In all cases the angle between the lines should be 45 degrees. .. At the moment in some cases i get +45 degress,+135,-135,-45 degrees. Is there a way to get the angle between two lines independant of the coordinate system??
Or any ideas?
Solved! Go to Solution.
09-26-2013 04:46 AM
09-26-2013 05:41 AM - edited 09-26-2013 05:43 AM
45 and -45 same difference- just wrap you angle into the range 0-180 degrees using 'wrap angle'... I would expect you to get +-45 and possibly +-(315), but 135 is incorrect. I don't know how you are measuring the angles (no experience with vision VIs), but if you are using inverse tangent in your calculations, replace it with the 2 input version to maintain 'quadrant awareness (TM)'... also the values you feed it, be consistent- always measure your deltaX and deltaY in the same sense (away from the intersection point) for both lines.
09-26-2013 07:55 AM
Just take the absolute value, and subtract from 180 deg if greater than 90 deg. If greater than 180 deg, subtract 90 deg until less than 180 deg (once or twice, depending). Simple math operations are so fast, you shouldn't see any delays unless you have to do this a gazillion times in a row.
Cameron
09-26-2013 08:17 AM - edited 09-26-2013 08:19 AM
Here is a small version of what i did. ( see attachment)
This is for one case with 4 different scan directions. Scan direction is actually for finding the edges of the area whee the angle have to be found.
In all 4 cases the result should be +44(approx).
Here i tried two different methods. One is to use the NI Vision IMAQ Lines intrsection VI where you get the angle between two lines
Other one is simple mathematics dot product of two vectors and finding the inverse cosine to get the angle
09-26-2013 08:59 AM - edited 09-26-2013 09:00 AM
09-26-2013 09:09 AM - edited 09-26-2013 09:35 AM
Or use complex math.... even simpler!
(now you can keep all in SGL representation ;))
(Not fully tested)
09-26-2013 09:29 AM - edited 09-26-2013 09:30 AM
@ToeCutter wrote:
, but 135 is incorrect.
No, 135 is the supplementary angle to 45 and mathematically equally correct for two intersecting lines.
09-26-2013 10:24 AM
@ Toecutter: I had already tried ' wrap angle ' function in another way. But couldnt get a reliable result.
@ altenbach: thank you very much for the help. Now am testing every possible angle orientation to see whether i get the desired result. 😄
Thanks you all
09-26-2013 02:28 PM
"No, 135 is the supplementary angle to 45 and mathematically equally correct for two intersecting lines."- that's a stretch. If one of the lines extends either side of the intersection point, you have your supplementary angle as one possible solution. That is clearly not the case in the problem as posed.