[Insight-users] direction of rotation
Luis Ibanez
luis . ibanez at kitware . com
Fri, 25 Jul 2003 17:42:01 -0400
Hi Michael,
The Versor components should be computed as you do for Quaternions,
that is, you should use : sin( angle/2 ) instead of just the angle,
the function should be:
double* CalculateVersorTransformParameters(double phi, double nx, double
> ny, double nz) {
> double* params = new double[3];
> double abs = sqrt (nx * nx + ny * ny + nz * nz);
> double angle = phi * PI / 180;
> params[0] = nx / abs * sin( angle / 2 );
> params[1] = ny / abs * sin( angle / 2 );
> params[2] = nz / abs * sin( angle / 2) ;
> return params;
> }
Not
> params[0] = nx / abs * angle;
...
A Versor is simply a unit Quaternion.
For the Euler angles, there is not equivalence to the angle, as you
are computing it right now. That's actually one of the great
disadvantages of using Euler angles. It is an ambiguous specification
for rotations.
You cannot get the three Euler angles by projecting a rotation angle
along the axis of coordinates. It is infact quite difficult to get
the euler angles from a quaternion since the Euler angles (as
implemented in this transform) are the equivalent of :
1) rotate around axis X by angle = angleX, then
2) rotate around axis Y by angle = angleY, then
3) rotate around axis Z by angle = angleZ
So, it is actually the composition of three orthogonal Versors.
If you were finding your way back it will be simpler to just use
the three angles angleX, angleY and angleZ for computing the
rotation matrix, and then from the matrix compute the equivalent
versor. Note however that what you have to set as paramters of the
Euler3D transfrorm is not the components of the versor, but just
the direct values of angleX, angleY and angle Z
Regards,
Luis
--------------------
Michael Kuhn wrote:
> Hi,
>
> I'm trying to transform an object with a QuaternionRigidTransfrom as
> well as with an Euler3DTransform. I'm feeding the transforms with the
> same angle, axis and translation. The output of the two transforms
> differs in the direction of the rotation. Using the Quaternion
> transform, the object is rotated by phi degrees to the left (when the
> z-Axis points towards me) and using the Euler3DTransform, its rotated by
> phi degress to the right. Below the code that calculates the paramters.
> Is there something wrong with my calculation of the transform parameters?
>
> double* CalculateQuaternionTransformParameters(double phi, double nx,
> double ny, double nz, double x, double y, double z)
> {
> double* params = new double[7];
> double mag = sqrt (nx * nx + ny * ny + nz * nz);
> // convert phi from degrees to rad
> double angle = phi * PI / 180;
> params[0] = nx / mag * sin(angle / 2);
> params[1] = ny / mag * sin(angle / 2);
> params[2] = nz / mag * sin(angle / 2);
> params[3] = cos(angle / 2);
> params[4] = x;
> params[5] = y;
> params[6] = z;
> return params;
> }
>
> double* CalculateVersorTransformParameters(double phi, double nx, double
> ny, double nz) {
> double* params = new double[3];
> double abs = sqrt (nx * nx + ny * ny + nz * nz);
> double angle = phi * PI / 180;
> params[0] = nx / abs * angle;
> params[1] = ny / abs * angle;
> params[2] = nz / abs * angle;
> return params;
> }
>
> double* CalculateEuler3DTransformParameters(double phi, double nx,
> double ny, double nz, double tx, double ty, double tz)
> {
> double* params = new double[6];
> double* versor = CalculateVersorTransformParameters(phi, nx, ny, nz);
> params[0] = versor[0];
> params[1] = versor[1];
> params[2] = versor[2];
> params[3] = tx;
> params[4] = ty;
> params[5] = tz;
> return params;
> }
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>