LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Angle between two line independant of the universal Reference coordinate system

Solved!
Go to solution

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?

 

Angle.JPG

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 1 of 13
(3,682 Views)

Hi Nghtcrwlr,

 


At the moment in some cases i get +45 degress,+135,-135,-45 degrees.


 

In which cases?

How do you get the angle? By standard (vector) mathematics?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,678 Views)

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.

0 Kudos
Message 3 of 13
(3,668 Views)

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

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 4 of 13
(3,652 Views)

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

 

AngleTest1.png

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
Message 5 of 13
(3,645 Views)
Solution
Accepted by topic author Nghtcrwlr

Try this:

 

 

Download All
Message 6 of 13
(3,631 Views)

Or use complex math.... even simpler!

(now you can keep all in SGL representation ;))

 

 

 

(Not fully tested)

Download All
0 Kudos
Message 7 of 13
(3,627 Views)

@ToeCutter wrote:

, but 135 is incorrect.


No, 135 is the supplementary angle to 45 and mathematically equally correct for two intersecting lines.

0 Kudos
Message 8 of 13
(3,615 Views)

@ 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

Nghtcwrlr

---------------------------------------------------------------------------------------------
*************************************
---------------------------------------------------------------------------------------------
0 Kudos
Message 9 of 13
(3,603 Views)

"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.

0 Kudos
Message 10 of 13
(3,586 Views)