W
W
wolf-98302014-07-19 18:14:30
Mathematics
wolf-9830, 2014-07-19 18:14:30

How can I correctly move a point on Cartesian coordinates around a circle?

Hello, I don't understand how to move a point around a circle on Cartesian coordinates, I did it like this:

x = x*cos(a) - y*sin(a)
y = x*sin(a) + y*cos(a)

but this method rotates the point about the origin. How can I make the point rotate around the point that I set myself?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
ManWithBear, 2014-07-19
@wolf-9830

Just move the origin to the second point.
For reflection:
The origin is (0;0). Rotate it:

x = (x-0)*cos(a) - (y-0)*sin(a) + 0
y = (x-0)*sin(a) + (y-0)*cos(a) + 0

Think a little further

A
Alexander Belov, 2014-07-19
@IPRIT

I did the rotation of the Moon around the Earth, simultaneously with the rotation of the Earth around the Sun, so I'll give you a hint.
Here is the rotation of the moon relative to the earth. Understand, like everything should be clear.
xx and yy - coordinates of the moon

// TrackBar1->Position — скорость вращения. Не обращайте внимания. Можете поставить 1.
xx = xx * cos(M_PI / 31.05819323 * TrackBar1->Position) + yy * sin(M_PI / 31.05819323 * TrackBar1->Position);

yy = -xx * sin(M_PI / 31.05819323 * TrackBar1->Position) + yy * cos(M_PI / 31.05819323 * TrackBar1->Position);

Image1->Canvas->Pen->Color = clGray;
Image1->Canvas->Brush->Color = clGray;

Image1->Canvas->Ellipse(
   width_window / 2 - earth_xx - xx - radius_moon, 
   height_window / 2 - earth_yy - yy - radius_moon, 
   width_window / 2 - earth_xx - xx + radius_moon, 
   height_window / 2 - earth_yy - yy + radius_moon
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question