Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning a single radian value into a Vector Direction

Tags:

c#

xna

I'm working in XNA.

I have a float value called "Rotation". It goes from -3.14 to 3.14. It specifies the rotation of a sprite.

I want to use this value to produce a Vector with values for rotation on the X and Y axis.

For instance, if the sprite is turned directly to the right, i want to get the value (1, 0).

If it's turned directly upwards, i want (0, -1). You get the picture.

How would i go about this?

like image 597
Andreas Eriksson Avatar asked Oct 27 '25 09:10

Andreas Eriksson


1 Answers

You use sine and cosine:

( Math.Cos(rotation), Math.Sin(rotation) )
like image 60
Guffa Avatar answered Oct 29 '25 23:10

Guffa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!