Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
gra
Feb 21, 2006
I'm working in DirectX/C++ just now. At the moment, I move things along the x and y axis and rotate them around the z axis - but I want to move the object "forward" along the heading it's been rotated to (I'm thinking asteroids - where the ship moves along the direction it's heading). Any idea/tutorials on how to do this?

Adbot
ADBOT LOVES YOU

gra
Feb 21, 2006

Ugg boots posted:

Just some simple vector math, really. Instead of moving the ship 1 unit in the Y direction, to move it forward just move it cos(angle) in the X direction and sin(angle) in the Y direction. If you're not keeping an angle, and your direction is in the form of a vector, just normalize that vector (let's call it V) and move Vx * speed in the X direction and Vy * speed in the Y direction.

That's great, thanks! I've almost got this working with vectors (it's OK when I'm at the origin, but not when I move about, so I think I'm forgetting to multiply something somewhere). My next question then is - is there any way to get the angle you've rotated from a rotation matrix?

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply