PDA

View Full Version : Re: calculation of 2D angles



Allan Carman, X 7455
01-05-2003, 12:41 AM
Dear All,

Unfortunately my response to the calculation of 2D angles did not appear in the
final summary of responses (although it was too late to make the first summary).
A short algorithm is presented below with the original response included.

//with (x,y) a unit vector, the angle from the right horizontal (x-axis) is
angle = acos(x);
if(yDear Chris,
>
>Sorry I missed the making the summary of replies, I have only just read you
>email.
>
>The problem is to calculate the segment angle from the vector joining points
>(x1,y1) and (x2,y2) (the origins of two adjacent segments), where the angle is
>relative to the positive X axis. An alternative way avoiding using atan and
>reducing the number of if() then {} statements is:
>a) define a unit vector from point 1 to point 2 called (x,y).
>b) define theta1 = acos(x) and theta2 = asin(y).
>c) if(theta2>=0.0) then {angle = theta1}
>For calculating the angle as both positive and negative rotations from the X axis
>(ie. +-180)
>c) if(theta2For calculating the angle as positive only rotations from the X axis (ie. +360)
>c) if(theta2
>Hope the helps
>
>Allan Carman
>
>School of Physiotherapy
>University of Otago
>Dunedin, NZ.

---------------------------------------------------------------
To unsubscribe send SIGNOFF BIOMCH-L to LISTSERV@nic.surfnet.nl
For information and archives: http://isb.ri.ccf.org/biomch-l
---------------------------------------------------------------