PDA

View Full Version : Re: Calculation of 2D Angles ('CAST' problem)

Ton Van Den Bogert
01-08-2003, 05:49 AM
I think my equations are still OK. These three equations produce
values for ph,th, and ps that, when plugged into the big equation
for T, give the attitude matrix that was measured. Hence, these
angles are a correct description of the motion that was measured.
The problem that Young-Hoo mentions is related to uniqueness.

By using the sqrt() function when computing theta, I restrict
theta to a range between -90 and +90 degrees (since the second argument
of ATAN2 is positive). This 180 degree range for the second rotation
is a common convention for cardanic angles, this is needed to obtain unique
angles. If theta is not restricted like this, there would be two
sets of angles that produce the same attitude matrix, which is essentially
the problem described by Young-Hoo.

Once it is understood that theta is always between -90 and +90 degrees,
there is no longer a problem.

Ton van den Bogert

"Young-Hoo Kwon, Ph.D." wrote:
>
> Dear Ton and all,
>
> I'd like to point out a mistake in your summary.
>
> > As in Kwon3D, we label these matrix elements as t11, t12, t13, etc.
> > Using such an attitude matrix, obtained from measurements, the joint
> > angles can be easily extracted as follows:
> >
> > ph = atan2(-t32,t33)
> > th = atan2(t31,sqrt(t32*t32+t33*t33))
> > ps = atan2(-t21,t11)
> > (..sqrt is the square root function)
> >
>
> ph = atan2(-t32,t33)
>
> is not right because
>
> atan2(-t32,t33) = atan2(sin(ph)cos(th),cos(ph)cos(th))
>
> is not equivalent to
>
> atan2(sin(ph),cos(ph)).
>
> It depends on the sign of cos(th). If this is negative, you will have
>
> atan2(-sin(ph),-cos(ph))
>
> instead. Likewise,
>
> atan2(t31,sqrt(t32*t32+t33*t33)) = atan2(sin(th),sqrt(cos(th)^2))
>
> is not equivalent to
>
> atan2(sin(th),cos(th))
>
> because sqrt(a2) can be either +a or -a, etc.
>
> I agree that the use of ATAN2 is relatively more convenient. I have used FORTRAN, QuickBASIC, C, C++, and now Visual C++. The function has evolved accordingly and atan
> 2 was forgotten in the process somehow. I will update my function using atan2. (^_^)
>
> Young-Hoo Kwon

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