I don't know much trig myself, but sin/cos are extremely basic, and they should be all you need.
Imagine a circle with a radius of 1 and the center of the circle as position 0,0.
Now put your finger on the right-most point of the circle's edge and trace the edge counter clockwise.
The Y coord of where your finger is forms a sine wave.
The X coord of where your finger is forms a cosine wave.
Therefore we can get any point on the circle's edge. All we need is the angle.
Given an angle, the point can be very simply found:
1 2
|
double x = cos(angle);
double y = sin(angle);
|
No matter what angle you use, this point (x,y) is a distance of 1 from position (0,0)
To scale that to different distances all you have to do is multiply (x,y) by your scalar.
For example, let's say you want to move 10 pixels at a 45 degree angle:
1 2 3 4 5 6 7
|
double deg = 45; // the angle
double move = 10; // how much we want to move
double rad = 45 * pi / 180; // convert degrees to radians
xpos += cos(rad) * move; // so easy!
ypos += sin(rad) * move;
|