So I'm a Mathtard

BlitzMax Forums/BlitzMax Programming/So I'm a Mathtard

Kanati(Posted 2011) [#1]
I have a sprite class... and I want to have a method that updates its location.

So say I have X and Y... And I have an angle (in degrees because my brain works in degrees)... and I have a velocity...

I think I need something like the following:

x = x + ( velocity * cos ( angle ) )
y = y + ( velocity * sin ( angle ) )

But is that angle in degrees or radians? Math sucks. :D


GfK(Posted 2011) [#2]
Its in degrees. I always use:
x = Cos(angle) * velocity + x
y = Sin(angle) * velocity + y

...which is the same thing, written differently.


Kanati(Posted 2011) [#3]
Sounds good to me. Thanks. :)


dynaman(Posted 2011) [#4]
Blitz is in degrees, other languages often (usually?) use radians.


Pengwin(Posted 2011) [#5]
@dynaman...I spent days debugging code once, until I realised that.Doh!


Jesse(Posted 2011) [#6]
if anyone does not know, for the purpose of converting code from any language that uses radians to degrees or degrees to radians:
radians to degrees:
ToRAd = Pi/180
rad = degrees*ToRad

degrees to radian:
ToDeg = 180/pi
deg = radians*ToDeg


if Pi is not defined:

Pi = 3.1415926535897931