Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

Converting Degrees/Radian to Vector2 is messy

$
0
0
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

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>