Posted 30 May 2013 - 05:30 AM
Hi,
I have been going on a bit of a maths rampage, trying lots of new things to do with vectors but one thing has left me completely stumped.
I made a function that should give you the coordinates of a point that is [length] away from another point at [angle] degrees:
For something like 45 deg it works but when I put in 180…It really doesn't, it returns -20, and 2.44….( the x, y is 0, 0 and length is 20 )
I have no idea why it does this and could really do with some help
Thanks
I have been going on a bit of a maths rampage, trying lots of new things to do with vectors but one thing has left me completely stumped.
I made a function that should give you the coordinates of a point that is [length] away from another point at [angle] degrees:
local angle = math.rad( angle )
local x2 = x + math.cos( angle ) * length
local y2 = y - math.sin( angle ) * length
return x2, y2
So this should work right?For something like 45 deg it works but when I put in 180…It really doesn't, it returns -20, and 2.44….( the x, y is 0, 0 and length is 20 )
I have no idea why it does this and could really do with some help
Thanks