• Advertisement

Archived

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

turning a vector 90 degrees

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

I have an asteriod and when you shoot it. I have 2 smaller asteriods appear. What I am tryinig to do is to make 2 smaller asteriods appear to the side and move in opposite direction of the large asteriod. The large asteriod has a position vector, velocity vector and a direction vector. I was wondering when I shoot the asteriod how do I make the 2 smaller asteriods appear 90 from the direction vector of the large asteriod. I have tried the following and they don't seem to work right: newAstrDir.x = (largeAstrDir.x) * cos(D3DX_PI/2) -largeAstrDir.y* sin(D3DX_PI/2); newAstrDir.y = (largeAstrDir.x) *sin(D3DX_PI/2) + largeAstrDir.y * cos(D3DX_PI/2); and newAstrDir.x = sqrt((largeAstrDir.x) * (largeAstrDir.x) + (largeAstrDir.y) * (largeAstrDir.y)) * cos(D3DX_PI/2); newAstrDir.y = sqrt((largeAstrDir.x) * (largeAstrDir.x) + (largeAstrDir.y) * (largeAstrDir.y)) *sin(D3DX_PI/2); Thanks for the help [edited by - l3arknight on March 6, 2004 7:15:03 PM]

Share this post


Link to post
Share on other sites
Advertisement
The great thing about rotating 2D vectors by 90 degrees is that all you have to do is switch some components. Given a direction vector (x,y), two vectors perpendicular to it are (y,-x) and (-y, x). This can be proven knowing the dot product between orthogonal vectors is 0. xy + y(-x) = x(-y) + yx = 0. Normalize as/if necessary.

Share this post


Link to post
Share on other sites

  • Advertisement