# Why rotation of 1.57 radian in x would face downwards?

This topic is 866 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

D3DXQuaternionRotationYawPitchRoll(&quatRot, rot.x, rot.y, rot.z);
D3DXMatrixTransformation(&matWorld, &scaleCenter, NULL, &scale,    NULL, &quatRot, &pos);

The object local axis aligns to the world axis,
that is the front of the object is facing positive x
and I give this direction facing right.
yet, +ve x in the world is facing right.
But When I rotate the object by rot.x of 1.57 radian, it is facing downwards...
Why not facing upwards? I don't get it

Does it mean the directx coordinate is left-handed, so that a positive turn is clockwise?
Thanks
Jack

Edited by lucky6969b

##### Share on other sites
Are your XYZ to yaw-pitch-roll correct? According to D3DXQuaternionRotationYawPitchRoll, yaw should be +Y, pitch should be +X, and roll should be +Z (or -Z, depending on LH or RH).

Since your model is facing +X, you might want to swap pitch and roll here.

##### Share on other sites

So I've checked,

In DirectX,

The yaw (around y-axis) of radian 1.57 is indeed facing down,

and radian of 4.7 is facing up?

To fastcall22,

Actually I've put up a D3DXVECTOR3(1.57,0,0) in the rotation variable

and aggregate in this call, so the x element of the rotation variable is still referring

to the yaw in the D3DXQuaternionYawPitchRoll call (around y-axis)

that is with a left-turn (anti-clockwise) to have positive radian?

Update:

Okay,

a few hacks, I made the model facing left when exporting,

so 1.57 is facing up now

But 3.14 is facing right now, because increasing radian is still taking clockwise turn, quite hairy...!

Thanks

Jack

Edited by lucky6969b

##### Share on other sites

the directx coordinate is left-handed

by default, yes.

that is with a left-turn (anti-clockwise) to have positive radian?

new_rotation = (2 * pi) - old_rotation

so if you want to turn 1.57 left, you new rotation is 2pi-1.57 = 3pi/2 (90 degrees left, the long way around)

a similar fixup is required to convert a unit circle heading (IE atan) to the compass heading for a target. the first is measured counter clockwise from the positive x axis, while the second is measured in a clockwise direction from the positive z direction (in a 3d game w/ left hand coordinate system, and in the positive y direction on the unit circle).

you may also find life goes easier if you define local positive z to be forward, local positive y as up, and local positive x as right, both in the game, and when you export. then everything matches dx's default left hand system.

Edited by Norman Barrows

1. 1
2. 2
Rutin
24
3. 3
4. 4
JoeJ
19
5. 5

• 14
• 26
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631771
• Total Posts
3002253
×