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

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

 September 8, 2005, 22:28 Finding angle from line1 to line2 in ccw sense(2d) #1 zonexo Guest   Posts: n/a Sponsored Links 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, 04:06 Re: Finding angle from line1 to line2 in ccw sense #2 upwind 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, 06:40 Re: Finding angle from line1 to line2 in ccw sense #3 zonexo 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.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post pvrao CFX 4 June 3, 2015 07:50 hsieh Open Source Meshers: Gmsh, Netgen, CGNS, ... 32 September 13, 2011 05:50 g_niro Main CFD Forum 0 February 2, 2011 18:24 kiran CFX 3 April 17, 2008 22:43