I one more stumble with quaternions a little, and hope someone here knows the missing part
(note that i say substract in logical not mathematical terms, as I know that a real substractions make no sense here)
Basically I have two quaternions (overly simplified example)
The rotation of a PlayerObject
The Cameras Rotation.
Now I want to get the difference on the PlayerObjects local yaw.
So basically
“substract”
the PlayerObject Rotation from the CameraRotation -> giving me a PlayerLocal rotation to the viewrotation
converting that to angles
-> do my stuff with the angles[1] part
Now I cant figure out that part that "subtract"s the rotations to be correct.
For a simple test case I have to identical valid rotations, and just “substract” them , my expectation is that I should get the identity Quaternion out of this.
-> Eg there is no local rotation if both are equal.
However I fail to get the calculations right or even nearly right.
Any help would be really nice.
My current TestCase is:
[java]
package de.visiongamestudios.server.system;
import com.jme3.math.FastMath;
import com.jme3.math.Quaternion;
public class QTest {
public static void main(final String[] args) {
final float[] initValue = new float[3];
initValue[1] = 90 * FastMath.DEG_TO_RAD;
final Quaternion player = new Quaternion();
player.fromAngles(initValue);
final Quaternion cam = new Quaternion();
cam.fromAngles(initValue);
player.negate();
final Quaternion res = cam.mult(player);
System.out.println("Player to Cam Rotation " + res);// expectiong 0,0,0,1 here as both
//quaternions are the same, so no further rotation should be required
//However ouput0 is "Player to Cam Rotation (0.0, -0.99999994, 0.0, 0.0)"
}
}
[/java]