I want to move one object (dot) in circular path.
By using x and y position of that object.
Thanks.
I want to move one object (dot) in circular path.
By using x and y position of that object.
Thanks.
x and y should satisfy $x^2+y^2=r^2$, where r is radius of the circle.
Edit:
How to move the point in circular path by adding value of x and y? I want to create a circular path by looping the formula. – Ganapathy
Ans: let
x=rcos(t), y=rsin(t)
loop over t
Is this part of a piece of software? Clarification on what you need would be very helpful.
If the object each frame has a velocity vector which it follows, just rotate the velocity vector through some fixed angle each frame. The easiest way would be to build a rotation matrix and multiply by the matrix. In a very naive implementation, you would then add the velocity to the position vector each frame. In most applications, this is insufficient, and it is preferable to use Verlet integration, mainly in the presence of acceleration.
Or you can parameterize the points on the circle as a function of time using the relations $x = c_x + r\cos(t), y = c_y + r\sin(t)$ for $(c_x,c_y)$ the circle's center, $r$ its radius, and $t$ the time.
There are a few ways to choose from, but a nice one that doesn't require per-step trig functions (so can be calculated by a computer very quickly) is the midpoint circle algorithm.
Otherwise, you can use x=cos(theta)*radius, y=sin(theta)*radius for 0 < theta < 360.