Rotate point $\langle x,y,z\rangle$ a specific angle around axis $\langle u,v,w\rangle$

67 Views Asked by At

I have a set of points in the form $\langle x,y,z\rangle$. I want to rotate each of them around the $y$-axis $\langle0,1,0\rangle$ about 20 degrees clockwise. I know this probably involves some matrix operations.

I found a couple of similar questions:

3D Cartesian Coordinates System revolve around a specified axis

Rotate 3D Point Around Point

I have very little math experience, so please dumb it down a bit. I probably won't understand much terminology. I took calculus 3 and differential equations several years ago.

2

There are 2 best solutions below

0
On

You will need to multiply them by a rotation matrix of the form, $$ R(\theta) = \left[ \begin{array}{ccc} \cos(\theta) & 0 & \sin(\theta) \\ 0 & 1 & 0 \\ -\sin(\theta) & 0 & \cos(\theta) \end{array} \right] $$

Bear in mind that the convention on most computers specifies $\theta$ in terms of radians rather than degrees. $360^o$ is $2\pi$ radians.

0
On

This is essentially 2D rotation, since the y coordinate is not changed by the rotation (it is an eigenvector of the rotation matrix) it is a rotation on the plane XZ. That means there are only two coordinates that change: x and z.

The polar coordinates of a vector $v$ in a plane are the pair of angle and radius: $(\theta, r)$. The angle is measured from the x-axis. From geometry we know that forming a right triangle with vector $v$ as hypothenuse we can get the cartesian coordinates of $v$ as:

$x = r \cos(\theta)$

$z = r \sin(\theta)$

The rotation of vector $v$ by an angle $\alpha$ will be just:

$x' = r \cos(\theta + \alpha)$

$z' = r \sin(\theta + \alpha)$

Now, that is using the polar form of $v$ to calculate the rotation of $v$ in cartesian coordinates. We can get rid of polar coordinates in the following way.

Recall the trigonometric identity for the $\cos(\theta + \alpha)$ and $\sin(\theta + \alpha)$:

$\cos(\theta + \alpha) = \cos(\theta) \cos(\alpha) -\sin(\theta) \sin(\alpha)$

$\sin(\theta + \alpha) = \sin(\theta) \cos(\alpha) + \sin(\alpha) \cos(\theta)$

Replacing in polar rotation we get:

$x' = r \cos(\theta) \cos(\alpha) - r \sin(\theta) \sin(\alpha)$

$z' = r \sin(\theta) \cos(\alpha) + r \sin(\alpha) \cos(\theta)$

Now we can use the fact that $x = r \cos(\theta)$ and $z = r \sin(\theta)$ to get:

$x' = x \cos(\alpha) - z \sin(\alpha)$

$z' = z \cos(\alpha) + x \sin(\alpha)$

$y' = y$

Now we can express that linear transformation in matrix form:

$R = \left[ \begin{array}{ccc} \cos( \alpha ) & 0 & -\sin(\alpha) \\ 0 & 1 & 0 \\ \sin(\alpha) & 0 & \cos(\alpha) \end{array} \right]$

So $v' = R v$.