ID:1713114
 
Code:
var/Angle=rand(0,360)
var/Dist=64
pixel_x = cos(Angle)*Dist
pixel_y=sin(Angle)*Dist


Problem description:This is code that I had recovered from digging deep into the forums. I sort of understand the math in the code from testing it and configuring it. But I'm having trouble actually applying this concept to objects that move. This code just makes it appear. Also, I know there is a library called absolute positions that goes over angles in pixel movement. I already tried understanding, it but the math overwhelms me. Can someone help me understand the math and the logic of angles so that I can apply it to my code?


The internet is a big place. You can learn about trigonometry just by searching for it.
In response to Kaiochao
Kaiochao wrote:
The internet is a big place. You can learn about trigonometry just by searching for it.

Just to clarify, I know the logic of the unit circle and the function of sin and cos. But random pluses and minuses in your library confuse me. I get the gist of what you're doing in absolute positions, but i just don't know exactly what you're doing with the numbers. I've already took a trig class too. It's possible that I may have forgotten some concepts or it's just hard for me to actually apply the math to coding.
In response to Bomber96
            //  Shift the mover's position by a certain distance and angle.
// Angle increases clockwise from NORTH.
// It's convenient for projectiles, but you would actually
// be better off storing a vector to Translate() by, in the
// case of an object moving with a constant velocity
// every frame.
Project(Distance, Angle, Dir = 0)
if(!Distance) return
return Translate(Distance * sin(Angle), Distance * cos(Angle), Dir)

This is the only place where sin and cos show up.

The x-component of an angle from the vertical axis is given by Distance * sin(Angle), and the y-component is given by Distance * cos(Angle).

For a unit circle, (sinθ, cosθ) is a point on the circle at the angle θ from the vertical. (That is, the angle goes clockwise from 12 on a clock). If you "scale" that point (which is really a vector), you get a vector at that same angle with whatever magnitude you scale the unit circle by.