E
Elgarion
Guest
Hello everyone,
I'm stuck with a math problem. At first I thought it would be simple, but I can't figure it out :
Imagine a circle A, with a point B orbiting on it.
Mechanically, the program should take the point B at position 1 (B1) and move it to a certain angle, relatively to a center A, in position 2 (B2). We know the coordinates Bx1, By1, Ax, Ay and the angle.
In summary :
- I have the orbiting point B : Bx1 and By1
- I have the center A : Ax and Ay
- I have the angle, in degrees
= > I need the values Bx2 and By2 of B's new position.
I hope it's clearer. Thank you so much for your effort!
I tried with the code below, but things get quite clunky.
Any clue ?
EDIT : I modified this post in order to make it clearer.
I'm stuck with a math problem. At first I thought it would be simple, but I can't figure it out :
Imagine a circle A, with a point B orbiting on it.
Mechanically, the program should take the point B at position 1 (B1) and move it to a certain angle, relatively to a center A, in position 2 (B2). We know the coordinates Bx1, By1, Ax, Ay and the angle.
In summary :
- I have the orbiting point B : Bx1 and By1
- I have the center A : Ax and Ay
- I have the angle, in degrees
= > I need the values Bx2 and By2 of B's new position.
I hope it's clearer. Thank you so much for your effort!
I tried with the code below, but things get quite clunky.
Code:
// for any 'my angle' variable ranging from 0 to 359
my_angle = 90 // example
// determining the center
temp_X = Bx - Ax ;
temp_Y = By - Ay;
NewPosition_Bx = Ax + (temp_X * cos(my_angle)) - (temp_Y * sin(my_angle))
NewPosition_By = Ay + (temp_X * sin(my_angle)) + (temp_Y * cos(my_angle))
EDIT : I modified this post in order to make it clearer.
Last edited by a moderator: