# 3D Motion Problem

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

## Recommended Posts

Heya again :) I was wondering if somone could tell me what is causing my model to rotate incorrectly. Here is an AVI movie showing my problem www.NHDigitek.com/XFlightFraps.rar When i sat down with my graph paper to figure out how i would make it rotate all the vectors in 3 axis as a local system i figured out that i needed 3 vectors to represent each axis and the way it faces. I might have gone about this the completely wrong way. But on my model/object i have 4(important) vectors Position (x,y,z) XVector(X,Y,Z) yVector(X,Y,Z) zVector(X,Y,Z) To rotate about the Z axis i use the following code:
Public Sub RotateZ(Angle As Double)
With Normalize3dVector(OperatorMINUS(OperatorMP(XVector, Cos(Angle * PIdiv180)), OperatorMP(YVect, Sin(Angle * PIdiv180))))
XVector.x = .x
XVector.Y = .Y
XVector.Z = .Z
End With
'Update the yVect wtih cross product
YVect.x = CrossvectorProduct(ZVector, XVector).x * -1
YVect.Y = CrossvectorProduct(ZVector, XVector).Y * -1
YVect.Z = CrossvectorProduct(ZVector, XVector).Z * -1

SpatialRotation.Z = SpatialRotation.Z + Angle
End Sub

And instead of the "SpatialRotation += angle" bit at the end i have also tried
If Angle < 0 Then
SpatialRotation.Z = SpatialRotation.Z - Icos(DotProduct(ZVector, XVector))
Else
SpatialRotation.Z = SpatialRotation.Z + Icos(DotProduct(ZVector, XVector))
End If

But still no sucess. Thanks in advance ~ John.

1. 1
Rutin
49
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• ### Forum Statistics

• Total Topics
633409
• Total Posts
3011722
• ### Who's Online (See full list)

There are no registered users currently online

×