Moving a point around a circle

670 Views Asked by At

we're currently working on a game which involves a character that rotates around a point.

We are using a rotation matrix to rotate a given a point (x,y) around another point by first translating to the origin, rotating and then translating back.

What we would like to do is to have the point accelerate into the rotation point by having the radius to the rotation point reduced over time.

Is there a way to factor in that movement by making an adjustment to the rotation matrix or is there a better way to do this?

1

There are 1 best solutions below

0
On BEST ANSWER

Ignoring your translation to and from the origin. if you have a rotation matrix $R(\theta(t))$ where $\theta(t)$ is angle as a function of time, you can also scale the matrix by some function of time. Say you want the distance from the object to the center of rotation to decrease linearly to zero over 10 units of time then you use the function

$$r(t) = 1 - t/10$$

Your rotation and scaling matrix becomes $r(t)* R(\theta(t))$ and you apply it at increments from $t=0$ to $t=10$.

Or you can use $r(\delta t) * R(\theta(\delta t))$ and repeatedly apply it.

-- For those asking why the OP uses translations. He translates the center of rotation to the origin, then applies matrices to transform around that center. Then undoes the origin translation. This is a standard method in computer graphics / game programming to apply a rotation or other linear transformation about a point other than the origin. A different method is to add an additional coordinate to the problem so that affine transformations can be represented as linear transformation in a higher dimensional space.