[ODE] Mapping to OpenGL axis system: not convinced
nlin@nlin.net
nlin at nlin.net
Fri Nov 23 09:34:01 MST 2001
Hello Ruud,
I am surprised no one jumped in with an explanation here, since a reversal
of coordinate systems would be a rather important issue, if it indeed were
the case in ODE. So, I attempted to reproduce your error. I was unable to.
You said:
> Especially take a look at the Z vector (0,-0.4,0.9). The Y is down; the car
> pitches downward. Now for orientation 2 (rotated 90 degrees in yaw):
> 0 0 1 => 0 -0.27 0.96
> 0 1 0 0 0.96 0.27
> -1 0 0 -1 0 0
>
> Here, although the same dBodyAddRelTorque(id,1000,0,0) was given, the car's Z
> vector indicates the car is now pointing UPward (Y=0.27 which is >0).
Starting with the following orientation:
-0.000000 0.000000 1.000000
0.000000 1.000000 0.000000
-1.000000 0.000000 -0.000000
set using the following code:
dMatrix3 R;
int ri=0;
R[ri++] = 0.0; R[ri++] = 0.0; R[ri++] = 1.0; R[ri++] = 0.0;
R[ri++] = 0.0; R[ri++] = 1.0; R[ri++] = 0.0; R[ri++] = 0.0;
R[ri++] =-1.0; R[ri++] = 0.0; R[ri++] = 0.0; R[ri++] = 0.0;
and using dBodyAddRelTorque(bodyID, 0.1, 0, 0)
I obtain after one frame the following orientation
0.000000 0.071051 0.997473
-0.000000 0.997473 -0.071051
-1.000000 -0.000000 0.000000
as printed out with the following code
const dReal* rot;
rot = dBodyGetRotation(obj[lasti].body);
printf("%f %f %f\n%f %f %f\n%f %f %f\n",
rot[0], rot[1], rot[2],
rot[4], rot[5], rot[6],
rot[8],rot[9],rot[10]);
This is NOT in agreement with your results. You got a slightly positive
y component for the z axis. I got a slightly negative component for the
y component of the z axis (as it should be, and as you expected).
Starting with the identity rotation matrix yields the same expected results
as you got.
Is it possible that your torque is so large that you are causing a
rotation more than 360 degrees, causing an apparent rotation in the
wrong direction?
Furthermore you mentioned
> viewed the source code, and dBodyAddRel*() does a multiplication with the
> body's R (rotation) member. But as I see it, this would convert World
> coordinates into Body coordinates, right? Instead, it seems to be used to
> calculate World coordinates *from* Body coordinates (which isn't right if I
> understand correctly).
If the body's rotation matrix is represented by R, then the matrix R
converts FROM coordinates expressed in frame R *TO* world coordinates -
which is indeed the correct behavior. Consider the vector (1,0,0). Assuming
this vector is in R coordinates, this means it is one unit along R's local
X axis. Multiplying this vector by R gives you the first column of R -
which is R's local X axis, in WORLD coordinates. So, R converts from
body coordinates to world coordinates.
Are you sure you don't have a mixup in your code?
Anyone else want to confirm/dispute my results?
-Norman
More information about the ODE
mailing list