#### Archived

This topic is now archived and is closed to further replies.

# need help with movement

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

## Recommended Posts

Hi, I can move an object easily enough along the z axis using:
  x -= (float)sin(-roty*(3.14f/180.0f)) * speed; z -= (float)cos(-roty*(3.14f/180.0f)) * speed; 
but how would i go about moving on all three axis''? Based not just on heading, but on tilt too. Thanks, Scott Email Website
"If you try and don''t succeed, destroy all evidence that you tried."

##### Share on other sites
Linear algebra dude. Use matrices and vectors. When you say heading, i think you mean translation. And when you say tilt, i think you mean rotation.
  Object::UpdatePosition(Vector dTranslation, float dxrot, float dyrot, float dzrot){ Matrix m; m.LoadIdentity(); m = Matrix::GetXRotation(xrot); m *= Matrix::GetYRotation(yrot); m *= Matrix::GetZRotation(zrot); m += dTranslation; m_vPosition = m * m_vPreviousPosition; m_vPreviousPosition = m_vPosition; // setup for next frame}

The implementation of a Matrix and Vector class has been left as an exercise for the reader.

(Don't you hate it when textbooks say that)

Edited by - Parveen Kaler on August 3, 2001 8:44:19 PM

##### Share on other sites
hehe, i just got through the quaternion rotations + matrices... was hoping i didn''t have to go back

thanks,
Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

##### Share on other sites
Yeah, you probably want to use quaternions for rotations to fend off that evil gimbal lock.

##### Share on other sites
anybody know of a good quaternion/matrix class(s) that will handle rotations and 3D movement?

purely C would be better, but i think i could manage either. Because classes i''m using right now are a cross of a bunch of different code, and they are just messing me up.

thanks,
Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

##### Share on other sites
I use directx 8''s vector and quanterion math stuff...

##### Share on other sites
i''m an OpenGL guy myself, would they still be usable?
and do they come with the SDK?

Scott

Email
Website

"If you try and don''t succeed, destroy all evidence that you tried."

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

• 38
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631708
• Total Posts
3001840
×