CFD Online Logo CFD Online URL
Home > Forums > Main CFD Forum

Finding angle from line1 to line2 in ccw sense(2d)

Register Blogs Members List Search Today's Posts Mark Forums Read

Sponsored Links

LinkBack Thread Tools Display Modes
Old   September 8, 2005, 22:28
Default Finding angle from line1 to line2 in ccw sense(2d)
Posts: n/a
Sponsored Links

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
  Reply With Quote
Sponsored Links

Old   September 9, 2005, 04:06
Default Re: Finding angle from line1 to line2 in ccw sense
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.
  Reply With Quote

Old   September 9, 2005, 06:40
Default Re: Finding angle from line1 to line2 in ccw sense
Posts: n/a
Ya i just found it on the web too. it's should work. thanks anyway. btw, the website is the algorithm is given in visual basic.
  Reply With Quote


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
finding flow angle pvrao CFX 4 June 3, 2015 07:50
Import netgen mesh to OpenFOAM hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05: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 22:43

Sponsored Links

All times are GMT -4. The time now is 23:17.