Setting the angle

Hi,

i am trying to make a simulator for something like this

im having trouble with the a and b rotation , i want to feed numbers in and rotate them accordingly, but im unsure how to do this.

In my update loop
tool.setLocalRotation(new Quaternion (0, 0, thread1.floatB, 0));
im guessing thats how you rotate it?

thanks

Quaternions do not work the way you think. The values in a quaternion are magic and you cannot set them manually and expect to get useful results.

You should brush up on your math and/or read some documentation.

[java]
someObj.setLocalRotation(
someObj.getLocalRotation().fromAngleAxis(
90FastMath.DEG_TO_RAD,
Vector3f.UNIT_Y
)
);
// or
someObj.setLocalRotation(
someObj.getLocalRotation().fromAngles(
90
FastMath.DEG_TO_RAD,
45FastMath.DEG_TO_RAD,
23
FastMath.DEG_TO_RAD
)
);
[/java]
Or you could just use the radian values… etc, etc.

But, you really ought to do what pspeed said. It takes no time to go through the tutorials and they are invaluable.

@pspeed said: Quaternions do not work the way you think. The values in a quaternion are magic and you cannot set them manually and expect to get useful results.

You should brush up on your math and/or read some documentation.

And in case you don’t buy the “magical” part… System.out.println the values of one and watch in amazement as the same value can mean two different things /boggle

When you read this:
“Any rotation in three dimensions can be represented as a combination of an axis vector and an angle of rotation. Quaternions give a simple way to encode this axis-angle representation in four numbers and apply the corresponding rotation to a position vector representing a point relative to the origin in R3.”

You have to ignore the angle axis part. It’s sort of erroneous. I hate it when articles mention that because it makes many people believe the values make some kind of sense when they don’t. A quaternion is not simply an axis and an angle. It’s a projection on a hypersphere and just happens to have a similar number of values. Unless you are comfortable thinking in the space of a 4 dimensional sphere then it is not feasible to understand a quaternion’s values.

As said, they are magic.

As potential proof that a Quaternion and an Angle Axis are not the same thing… imagine then angle axis axis:1,0,0, angle:0… then axis:1,0,0, angle:2 * PI… then axis 1,0,0, angle:4 * PI… these are all the same Quaternion.

But the article might make for interesting reading anyway.

Actually, this one is maybe a little better, I think:
http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/index.htm