Angular point movement

I forget the maths behind moving a point using its rotation in radians. I thought it was something like the code I have below, but it seems to be incorrect as it isn't moving in the correct direction.

1
2
3
4
5
6
7
8
double pointPos[2] = {10.0, 10.0};

double angleInRadians = M_PI / 2;
double angleInDegrees = angleInRadians * (180 / M_PI);
double speed = 5.0;

pointPos[0] += (sin(angleInDegrees) * speed);
pointPos[1] -= (cos(angleInDegrees) * speed);


Is it correct?
Suppose you want to rotate p around center by theta radians:
1
2
3
4
5
6
7
8
9
vector rotated;
if (p==center)
    rotated=p;
else{
    vector p2=p-center;
    double angle=atan2(p2.y,p2.x);
    double r=sqrt(p2.x*p2.x+p2.y*p2.y);
    rotated=center+vector(r*cos(angle+theta),r*sin(angle+theta));
}

Note: I'm not using any library or vector class in particular. I'm just writing the arithmetic in C++ notation.
Topic archived. No new replies allowed.