|
[Sponsors] |
Finding angle from line1 to line2 in ccw sense(2d) |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 8, 2005, 23:28 |
Finding angle from line1 to line2 in ccw sense(2d)
|
#1 |
Guest
Posts: n/a
|
Hello,
does anyone know of an algorithm which can find the angle from line1 to line2 in ccw (counter clockwise) sense (2d)? Angle between 2 lines can be found easily using dot product. however, the answer given is always < 180deg. i'm currently using this algorithm, which seems quite inefficient ... 1. find angle of line1 & 2 wrt x axis 2. find which quadrant each line is pointing in 3. from the above 2 ans, deduce the angle from line1 to 2 in an ccw sense e.g. if line1 & 2 are in 1st quadrant, 60deg & 40deg respectively so angle = 340deg problem with this code is that there's as much as 16cases to consider. Does anyone know of a shorter and more efficient algorithm? Thanks |
|
September 9, 2005, 05:06 |
Re: Finding angle from line1 to line2 in ccw sense
|
#2 |
Guest
Posts: n/a
|
I just thought of a shorter algorithm which I think should work but this needs to be verified; whether it is efficient also needs to be checked out.
1. Determine dot product as before and obtain the cosine of the angle. 2. Determine cross product i.e. line 1 X line 2 and this will give sine of the angle. 3. If sine and cosine are both positive or both negative the take the angle obtained in 1. as it is. If not define your counter-clockwise angle as 360 - the angle obtained in 1. Let me know if this works for you. |
|
September 9, 2005, 07:40 |
Re: Finding angle from line1 to line2 in ccw sense
|
#3 |
Guest
Posts: n/a
|
Ya i just found it on the web too. it's should work. thanks anyway. btw, the website is http://www.vb-helper.com/index.html. the algorithm is given in visual basic.
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
finding flow angle | pvrao | CFX | 4 | June 3, 2015 08:50 |
[Netgen] Import netgen mesh to OpenFOAM | hsieh | OpenFOAM Meshing & Mesh Conversion | 32 | September 13, 2011 06:50 |
Normal vector, slope and aspect angle | g_niro | Main CFD Forum | 0 | February 2, 2011 18:24 |
finding flow angle in linear cascade analysis | kiran | CFX | 3 | April 17, 2008 23:43 |