Jump to content
  • Advertisement
Sign in to follow this  
kVandaele

Updating position vector

This topic is 5411 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

Additional visualisation info I'm currently using a class to represent ships, the class having the following member vars: D3DXVECTOR3 m_Dir; D3DXVECTOR3 m_Up; D3DXVECTOR3 m_Pos; float m_fVel; while this is directx code, D3DXVECTOR3 is really just a vector with x, y, and z variables. m_Dir = directional vecotr, safe to assume it's normalised m_Up = up vector, not necessary here (i think) m_Pos = positional vector m_fVel = velocity value As you can see from the link, i tried to work this out in 2D first. Aside from having little clue as of yet how to do this in 3D, my end result was 4 square roots, each killing performance... Worse yet, this is an operation that would have to be done each frame -on nearly every single object- so speed is quite important.

Share this post


Link to post
Share on other sites
Advertisement
1. Normalize your direction vector.
2. Calculate the distance moved in per frame (speed * frames per second).
3. New position = old position + (direction * distance moved)

The normalization shouldn't really need any square roots if it starts normalized, and you rotate it properly. Otherwise it will require one square root.

Share this post


Link to post
Share on other sites
i was having problems with step 2, figuring out -if say velocity was 10- how much that would be in terms of x, y, and z...

riiiiiiiiight... since the direction vector is normalised that's no problem at all...

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!