Re: Rotating Mesh around X,Y,Z
- From: "Philip Taylor \( MS \)" <~ptaylor@xxxxxxxxxxxxx>
- Date: Fri, 27 May 2005 10:43:57 -0700
using quaternions is the typical approach to avoiding the gimbal lock
phenomenon that shows when using Euler angles.
a google search should be helpful.
"Jaret Brower" <browerjs@xxxxxxxxxxxxx> wrote in message
news:531F5343-E81F-47BB-BFC8-92BEC17F84C5@xxxxxxxxxxxxxxxx
>I think I need to rephrase slightly. What I want to do is rotate a mesh
> around all 3 axis at the same time. For example I first move my mesh
> 45deg
> around X, now I want to move it 20deg around Y (while keeping the X
> rotation), and then rotate around the Z 30deg, keeping the previous X and
> Y
> rotations.
>
> Depending on how i do my movements it some times works properly doing:
>
> device.Transform.World = RotateX(xangle)*RotateY(yangle)*RotateZ(zangle);
> or
> device.Transform.World = RotateYawPitchRoll(yangle,xangle,zangle);
>
> but I believe gimble lock is occurring when i do either of this methods,
> because eventually, when i rotate around the Z, it's actually rotating
> around
> the Y. Any more thoughts?
>
> "Rhett Gong [MSFT]" wrote:
>
>> We have a tutorial code in DX SDK which illustrate how to rotate a mesh
>> around Y axis. And you can find it under "Microsoft DirectX 9.0 SDK
>> (April
>> 2005)\Samples\Managed\Direct3D\Tutorials\Tutorial6" if you installed
>> DX9.0
>> sdk april 2005.
>> To make a test, you can change line 111 to:
>> device.Transform.World = Matrix.RotationX(Environment.TickCount/1000.0f);
>> or
>> device.Transform.World = Matrix.RotationZ(Environment.TickCount/1000.0f);
>> to make the mesh rotated around x or z axis.
>>
>> Basically, we use 3 matrix to rotate the mesh around x,y or z axis. For
>> more details on the transform matrix, you can reference following doc:
>> http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/directx9_c_
>> Summer_04/directx/graphics/programmingguide/FixedFunction/Transforms/matrice
>> s/rotation.asp
>>
>> I noticed you are using (1,0,0,XAngle) for the Quaternion rotation.
>> Describe (1,0,0,XAngle) as a matrix, it is:
>> | 1 0 0 0 |
>> | 0 -1 -2XAngle 0 |
>> | 0 2XAngle -1 0 |
>> | 0 0 0 1 |
>> That why you get the mesh looked bigger and bigger. When given a rotation
>> axis, you need to transform it to a quaternion with following formula:
>> q.x = sin(theta/2) * axis.x
>> q.y = sin(theta/2) * axis.y
>> q.z = sin(theta/2) * axis.z
>> q.w = cos(theta/2)
>>
>> Please let me know if my answer helps you resolve the problem. If there
>> is
>> anything more I can assist you, please feel free to let me know.
>>
>> Thanks,
>> Rhett Gong [MSFT]
>> Microsoft Online Partner Support
>> Get Secure! - www.microsoft.com/security
>> http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
>> &SD=msdn
>>
>> This posting is provided "AS IS" with no warranties and confers no
>> rights.
>>
>>
.
- Follow-Ups:
- Re: Rotating Mesh around X,Y,Z
- From: Jaret Brower
- Re: Rotating Mesh around X,Y,Z
- References:
- Rotating Mesh around X,Y,Z
- From: Jaret Brower
- RE: Rotating Mesh around X,Y,Z
- From: Rhett Gong [MSFT]
- RE: Rotating Mesh around X,Y,Z
- From: Jaret Brower
- Rotating Mesh around X,Y,Z
- Prev by Date: RE: Rotating Mesh around X,Y,Z
- Next by Date: Re: Rotating Mesh around X,Y,Z
- Previous by thread: RE: Rotating Mesh around X,Y,Z
- Next by thread: Re: Rotating Mesh around X,Y,Z
- Index(es):
Relevant Pages
|
Loading