Re: dotproduct rotations
- From: "Wessam Bahnassi" <wbahnassi@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 15 Apr 2006 17:05:19 -0400
The angle returned is the smallest angle between the two vectors, so you'll
need an additional sign check on one of the original vector's axis to decide
whether or not to add 180 degrees to the returned angle.
--
Wessam Bahnassi
Microsoft DirectX MVP,
Software Engineer
Electronic Arts Inc.
--
In|Structurez Arabic Gamedev Community
www.instructurez.com
"Pathogen" <Jaryth_Saryth@xxxxxxxxxxx> wrote in message
news:Oe5XlEIYGHA.3704@xxxxxxxxxxxxxxxxxxxxxxx
Okay i know the dotproduct of two vectors will give me the cos(theta)
angle
between them therefor the
theta = acosf(dotproduct(vector1,vector2)
this also has several possibilities of theta that can be determined using
the cross product here is my code
//y rotation
dataContainer.vRotation.y =
D3DXVec3Dot(&D3DXVECTOR3(0.0f,0.0f,1.0f),&temporary);
ret.vRotation.y = acosf(dataContainer.vRotation.y);
D3DXVec3Cross(&crossproduct,&D3DXVECTOR3(0.0f,0.0f,1.0f),&temporary);
if( crossproduct.y < 0.0f ){
ret.vRotation.y = -(ret.vRotation.y);
}
//z rotations
dataContainer.vRotation.z =
D3DXVec3Dot(&D3DXVECTOR3(1.0f,0.0f,0.0f),&temporary);
ret.vRotation.z =
acosf(dataContainer.vRotation.z/D3DXVECTOR3(1.0f,0.0f,0.0f)*temporary);
D3DXVec3Cross(&crossproduct,&D3DXVECTOR3(1.0f,0.0f,0.0f),&temporary);
if( crossproduct.z < 0.0f ){
ret.vRotation.z = -(ret.vRotation.z);
}
now the rotations around the y axis work perfectly but the rotations
around
the z does not it will only work in one direction... Has anyone any help
on
getting these rotation methods to work in direct3d?
.
- Follow-Ups:
- Re: dotproduct rotations
- From: Pathogen
- Re: dotproduct rotations
- References:
- dotproduct rotations
- From: Pathogen
- dotproduct rotations
- Prev by Date: dotproduct rotations
- Next by Date: Re: dotproduct rotations
- Previous by thread: dotproduct rotations
- Next by thread: Re: dotproduct rotations
- Index(es):
Relevant Pages
|