0

I have the orbit center point in x-y cords and radius between the center point and the orbiting point, along with the x-y cords of the orbiting. I need to update the orbiting points x-y cords so that it orbits the center point in a perfect circle. How can I do this? I have been stuck on it all day ...

1 Answers1

1

If i understand you correctly you want to rotate a point around a other

Point center;
int radius;
double angle; // in radians
// get the Vektor from center to orbit
Point orbit = center + new Point(cos(angle)*radius, sin(angle)*radius)

You can use the trigonometric functions sinus and cosinus to calculate the x and y position of a circle with radius 1. Then you multiply ith with your radius to get a citcle rith the radius radius. At last you shift the coordinates by your center point so the rotation is not centered by (0|0). (Now its centered around your center)

See here for mor information, or perhaps also here (its C++, but teh problem is nearly the same)

Community
  • 1
  • 1
Mikescher
  • 875
  • 2
  • 16
  • 35
  • How do I use the vector structure? I tried using the vector structure but the keyword isn't working. On msdn it says it is in System.Windows; which I have already included.. – charlie Barajas Feb 13 '14 at 06:55
  • You could either just define for yourself a class/struct Point (or Vektor - name it whatever you want :) ). Or you can just use double centerX, centerY. And remeber through the hole programm x and y seperately – Mikescher Feb 13 '14 at 08:48