# Converting Degrees/Radian to Vector2 is messy

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

## Recommended Posts

Hi Guys,

I was wondering if some one could give me some tips on converting Degrees/Radians to Vector2. Degrees to Radians and vice versa is fine.

Im using "new Vector2((float)Math.Sin(r), (float)Math.Cos(r));" to do my conversion to Vector2. Yes, I get that the equation is usually [cos(r) , -sin(r)] but my equation suits my current orientation and ultimately does not affect my problem.

The problem I'm facing is the conversion of 90° and 180° into Vectors. When converting them I get:

·         90° = [1, -4.371139E-08] - second value should be 0.

·         180° = [-8.742278E-08, -1] - first value should be 0.

I understand that 180° is technically out of range, but just indulge me on that one, the main issue is 90°. What I am missing with those E-numbers? How do I avoid them?

After writing this I thought of just including a lookup table for the 90° and 180° during the conversions, maybe, I guess it would depend on their precision. Assuming I do not change my orientation this should work right?

Thanks

Krom

Edited by Kromble
formatting

##### Share on other sites

Both those values are super tiny. They are essentially 0 -- just floating point inaccuracies. Nothing to worry about.

-4.371139E-08 = -0.00000004371139

##### Share on other sites

Ahh cheers thanks mate...

I guess the compiler can interpret this number fine.

Krom

1. 1
2. 2
3. 3
Rutin
15
4. 4
5. 5

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633679
• Total Posts
3013296
×