Hi,

I am using using Quats for rotation along X an Y axis. I need to apply
rotations according to the mouse drag amount. I have extended the Behavior
class and wrote MyMouseRotate class to do this.

But it doesnt work. I have read the archives and other material about
Quats for rotation but still I am not able to figure out where I am doing
wrong. Can  any of you please look at my code and help me to do in the
right way?

Thanks
Bhargavi

This is the piece of code I am using:
--------------------------------------------------------------

        targetTG.getTransform(transform3D);

        //Translate to Origin
        translate.setTranslation(new Vector3d(3980.47,-320.34,-205.63));
        transform3D.mul(translate);

        Quat4d qprev = new Quat4d();
        Quat4d qu; //= new Quat4d();

        //qu.set(new AxisAngle4d(1.0,.0,.0, rotateX*RADIANS));
        // I have also used AxisAngle instead of the constructor to create
Quat with no luck//

        double ang= rotateX*RADIANS;

        qu = new Quat4d(1.0 * Math.sin(ang/2),
                         0.0 * Math.sin(ang/2),
                         0.0 * Math.sin(ang/2),
                         Math.cos(ang/2)); //Quat for Xaxis

        transform3D.get(qprev);
        qprev.mul(qu);

        ang= rotateY*RADIANS;
        qu = new Quat4d(0.0 * Math.sin(ang/2),
                         1.0 * Math.sin(ang/2),
                         0.0 * Math.sin(ang/2),
                         Math.cos(ang/2));
        //qu.set(new AxisAngle4d(.0,1.0,.0, rotateY*RADIANS));

        qprev.mul(qu);

        transform3D.set(qprev);

        //Translate back from origin//
        translate.setTranslation(new Vector3d(-3980.47,320.34,205.63));
        transform3D.mul(translate);

        targetTG.setTransform(transform3D);
-----------------------------------------------------------------

===========================================================================
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