Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to create a simple animation of a bottle that is lying on X-Y plane, that spins around z-axis, where X axis and Y axis are perpendicular to each other, and along the plane of your monitor, while Z - axis is the line coming out of the monitor towards you, and perpendicular to the surface of the monitor.

What I am trying to do is, create a simple animated image which shows such a spinning bottle.

How do I represent such a 3-d motion in an image? Which math equations apply to such rotation?

And in this example, the bottle is lying on X-Y plane, but what if it is not exactly along X-Y plane, but 'tilted' in such fashion? How should I represent such rotation?

share|cite|improve this question
use a matrix transformation! – bgins Apr 6 '12 at 9:11
up vote 1 down vote accepted

This highly depends on what software you are using to implement this. In general a rotation is most often represented in the form of a matrix though. Rotation around z axis by an angle $\phi$ is $$ \begin{bmatrix}x'\\y'\\z'\end{bmatrix} = \begin{bmatrix}\cos(\phi) & -\sin(\phi) & 0\\ \sin(\phi) & \cos(\phi) & 0\\ 0 & 0 & 1\end{bmatrix} \cdot \begin{bmatrix}x\\y\\z\end{bmatrix}$$

This works for any object, no matter whether it is tilted or exactly in the x-y-plane. If you want other rotations around arbitrary axes or don't want to rotate around an axis through the origin just search the web for general rotation matrices...

share|cite|improve this answer

The above notion of using rotation matrices will be useful. As for implementation, you will have to first construct a path for movement (i.e. vary the angle $\phi$ constantly with time, and you can use the standard $\frac{2 \pi}{T}$ to determine the speed of rotation. However, to do this using matrices efficiently without recalculating sin/cos for each angle you will be using, simply find the frame rate you plan on using (i.e. time step), and then divide the period by the time step to find a new angle $\phi_{0}$. Then multiplying all existing points by the rotation matrix generated by $\phi_{0}$ at each time step will result in a smooth, and efficient rotation display.

Also note the problems with displaying the points. You must take into account point overlap. However, we should first consider how we are going to see the points in the first place. In order to do so, you must use a projection matrix given by $$ \left(\begin{matrix}1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 0 \end{matrix}\right) $$ However, we must take into account overlapping. There are many ways to deal with this. One way is to weight the points based on their distance from the viewer (i.e. their positive distance). You could also consider defining a surface parametrization of the bottle and occlude the side with lower z values if there are lines along the z axis that intersect with the bottle twice.

Hope this gives you a good enough of an idea on how to do this!

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.