Sign in to follow this  

3D Motion Problem

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

If you intended to correct an error in the post then please contact us.

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.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this