Hi,
When rotating a object around its three axises, you are not allowed to use
the objects you mentioned, however, when you rotate it only around one axis,
it is ok. I have not found some relevant classes, so you developed one
custom class to rotate a object. I completed one paper that can be
downloaded from my personal web site. The following gives its relevant
source codes, and theoretical analysis please read that paper at
http://vlab.ee.nus.edu.sg/~ccd ---> resume ---> reports.
----------------------------------------------------------------------------
-----
private Matrix3f comMat = new Matrix3f();
private void init()
{
comMat.m00 = 1.0f;
comMat.m01 = 0.0f;
comMat.m02 = 0.0f;
comMat.m10 = 0.0f;
comMat.m11 = 1.0f;
comMat.m12 = 0.0f;
comMat.m20 = 0.0f;
comMat.m21 = 0.0f;
comMat.m22 = 1.0f;
}
private Matrix3f coMatrix(int mode, float angle)
{
Matrix3f tempMat = new Matrix3f();
switch (mode)
{
case 1:
tempMat.m00 = (float)(Math.cos(angle));
tempMat.m01 = 0.0f;
tempMat.m02 = (float)(Math.sin(angle));
tempMat.m10 = 0.0f;
tempMat.m11 = 1.0f;
tempMat.m12 = 0.0f;
tempMat.m20 = (float)(-Math.sin(angle));
tempMat.m21 = 0.0f;
tempMat.m22 = (float)(Math.cos(angle));
break;
case 2:
tempMat.m00 = 1.0f;
tempMat.m01 = 0.0f;
tempMat.m02 = 0.0f;
tempMat.m10 = 0.0f;
tempMat.m11 = (float)(Math.cos(angle));
tempMat.m12 = (float)(Math.sin(angle));
tempMat.m20 = 0.0f;
tempMat.m21 = (float)(-Math.sin(angle));
tempMat.m22 = (float)(Math.cos(angle));
break;
case 3:
tempMat.m00 = (float)(Math.cos(angle));
tempMat.m01 = (float)(-Math.sin(angle));
tempMat.m02 = 0.0f;
tempMat.m10 = (float)(Math.sin(angle));
tempMat.m11 = (float)(Math.cos(angle));
tempMat.m12 = 0.0f;
tempMat.m20 = 0.0f;
tempMat.m21 = 0.0f;
tempMat.m22 = 1.0f;
break;
default:
}
return tempMat;
}
private void setRotation(TransformGroup Trans, float angle, Matrix3f
rotMat, int mode)
{
Transform3D rt3d = new Transform3D();
Trans.getTransform(rt3d);
rotMat.transpose();
rotMat.invert();
rotMat.mul(rotMat, coMatrix(mode, angle));
rt3d.setRotation(rotMat);
Trans.setTransform(rt3d);
}
pisitive Rotation around the x-axis setRotation(viewTrans,
ANGLESTEP, comMat, 1);
negative Rotation around the x-axis
setRotation(viewTrans, -ANGLESTEP, comMat, 1);
pisitive Rotation around the y-axis setRotation(viewTrans,
ANGLESTEP, comMat, 2);
negative Rotation around the y-axis setRotation(viewTrans,
ANGLESTEP, -comMat, 2);
Anything, please send mail to my personal address: [EMAIL PROTECTED]
Rgds,
Cheng Chang Dong
----- Original Message -----
From: "Norbert Dec" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 21, 2002 12:48 AM
Subject: [JAVA3D] Rotation (rotX, rotY, rotZ)
> Hi!
> My problem is, I'm sure for you experts its very simple, but I can't find
my
>
> way out...
>
> I use three buttons to control the rotation of an object (rotX, rotY,
rotZ).
> First it works fine, but after some "Button-Clicks" the object disappears.
>
> Why??
>
> Thanks
>
> Norbert
>
> sourcecode:
>
> case ROTATE_Y:
> trans.getRotationScale(getMatrix);
> Matrix3d yMatrix = new Matrix3d(1.0, 0.0, 0.0, 0.0, 1.0,
> 0.0, 0.0, 0.0, 1.0);
> yMatrix.rotY(Math.PI/4.0);
> yMatrix.mul(getMatrix);
> trans.setRotation(yMatrix);
> trans.getRotationScale(aktMatrix);
> transformGroup.setTransform(trans);
> break;
> case ROTATE_Z:
> trans.getRotationScale(getMatrix);
> Matrix3d zMatrix = new Matrix3d(1.0, 0.0, 0.0, 0.0, 1.0,
> 0.0, 0.0, 0.0, 1.0);
> zMatrix.rotZ(Math.PI/4.0);
> zMatrix.mul(getMatrix);
> trans.setRotation(zMatrix);
> trans.getRotationScale(aktMatrix);
> transformGroup.setTransform(trans);
> break;
> case ROTATE_X:
> trans.getRotationScale(getMatrix);
> Matrix3d xMatrix = new Matrix3d(1.0, 0.0, 0.0, 0.0, 1.0,
> 0.0, 0.0, 0.0, 1.0);
> xMatrix.rotX( Math.PI/4.0);
> xMatrix.mul(getMatrix);
> trans.setRotation(xMatrix);
> trans.getRotationScale(aktMatrix);
>
> transformGroup.setTransform(trans);
>
>
>
>
>
> --
> GMX - Die Kommunikationsplattform im Internet.
> http://www.gmx.net
>
>
===========================================================================
> 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".
===========================================================================
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".