Hi,

I am trying (have been trying for a while) how to calculate the angular
values around X, Y, and Z from a Matrix3d object.  I am trying to echo
positional data of a vrml object to the user.  I get the Transform3D object
from the TransformGroup vrml node and then get the matrix3d object and the
vector3d object from the Transform3D object.  From there I want to calculate
the angular position of the object.  Can anyone help me.  I am not a math
wizard, so any help would be appreciated.  The code I am using is as
follows:

public void updatePositions(TransformGroup tg)
{
        double                  x=0.0,y=0.0,z=0.0,a=0.0,b=0.0,c=0.0;
        double                  values[] = new double[4];
        Matrix3d                m = new Matrix3d();
        Vector3d                v = new Vector3d();
        Transform3D             t = new Transform3D();
        AxisAngle4d             aa = new AxisAngle4d();
        NumberFormat    nf = NumberFormat.getNumberInstance();

        nf.setMinimumIntegerDigits(1);
        nf.setMaximumIntegerDigits(9);
        nf.setMaximumFractionDigits(4);
        nf.setMinimumFractionDigits(4);
        nf.setGroupingUsed(false);

        tg.getTransform(t);
        t.get(m,v);

        //"X" axis
        x = v.x;
        xPos.setText(nf.format(x));

        //"Y" axis
        y = v.y;
        yPos.setText(nf.format(y));

        //"Z" axis
        z = v.z;
        zPos.setText(nf.format(z));

        //"A axis"
        a = Math.toDegrees(Math.acos(m.m22));
//      if (m.m21 > -1.0 && m.m21 < 1.0) a = 90.0 +
Math.toDegrees(Math.asin(m.m11));
//      else if (m.m21 <= -1.0) a = -180.0;
//      else if (m.m21 >= 1.0) a = 180.0;
        aPos.setText(nf.format(a));

        //"B Axis"
        b = Math.toDegrees(Math.acos(m.m00));
//      if (m.m02 > -1.0 && m.m02 < 1.0) b = 90.0 +
Math.toDegrees(Math.asin(m.m02));
//      else if (m.m02 <= -1.0) b = -180.0;
//      else if (m.m02 >= 1.0) b = 180.0;
        bPos.setText(nf.format(b));

        //"C Axis"
        c = Math.toDegrees(Math.acos(m.m11));
//      if (m.m10 > -1.0 && m.m10 < 1.0) c = 90.0 +
Math.toDegrees(Math.asin(m.m10));
//      else if (m.m10 <= -1.0) c = -180.0;
//      else if (m.m10 >= 1.0) c = 180.0;
        cPos.setText(nf.format(c));
}


Thanks for you help

Dean Keeler
CNC Connection Corporation
[EMAIL PROTECTED]

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to