**Rotating a shape**
i am trying to rotate a shape (which is at the origin) using the arrow keys for direction of rotation. But when it is run, my shape rotates incorrectly (as in it will make some major turns at certain angles) and i cant see how this is happening. Heres the sample code in my own Behaviour Class:
private TransformGroup targetTG; //the target TG that is changed
private Transform3D rotationH = new Transform3D(); //T3D for rotation in X axis
private Transform3D rotationV = new Transform3D(); //t3D for rot in Y
private double angleH = 0.0; //the rotation in X
private double angleV = 0.0; // the rotation in Y
public void processStimulus(Enumeration criteria) {
KeyEvent e = ((KeyEvent)(((WakeupOnAWTEvent)criteria.nextElement()).getAWTEvent() [0])); //gets the keycode of the button thats pressed
if( e.getKeyCode() == KeyEvent.VK_UP ) { //if UP arrow is pressed
angleH = (angleH + 0.1) % (2* Math.PI);
rotationH.rotX(angleH);
rotationH.mul(rotationV);
targetTG.setTransform(rotationH);
}
if( e.getKeyCode() == KeyEvent.VK_DOWN ) { //DOWN arrow
angleH = (angleH - 0.1) % (2* Math.PI);
rotationH.rotX(angleH);
rotationH.mul(rotationV);
targetTG.setTransform(rotationH);
}
if( e.getKeyCode() == KeyEvent.VK_LEFT ) { //LEFT arrow
angleV = (angleV + 0.1) % (2* Math.PI);
rotationV.rotY(angleV);
rotationV.mul(rotationH);
targetTG.setTransform(rotationV);
}
if( e.getKeyCode() == KeyEvent.VK_RIGHT ) { //RIGHT arrow
angleV = (angleV - 0.1) % (2* Math.PI);
rotationV.rotY(angleV);
rotationV.mul(rotationH);
targetTG.setTransform(rotationV);
}
this.wakeupOn(new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED));
}
whats going wrong?

