4

If I have vectors $a = (1,0,0)$, $b = (0,1,0)$, and $c=(0,0,1)$ and I want to rotate them counterclockwise at rate $r$ rad/sec around vector (1,1,1). What are the formulas for $a, b, c$?

NKS
  • 4,392

3 Answers3

2

As an alternative, you can use quaternions!

Quaternions are an extension of the complex numbers that very nicely represent rotations in three dimensions. If you want to rotate by an angle $\theta$ around an axis $\langle x, y, z \rangle$, you first create a quaternion as follows:

$$q = \cos(\frac{\theta}{2}) + x \sin(\frac{\theta}{2}) i + y \sin(\frac{\theta}{2}) j + z \sin(\frac{\theta}{2}) k$$

Now you can apply this to a point $a$ to rotate it:

$$a' = q a \bar{q}$$

(where the overbar indicates the "conjugate": flip the signs on every term except the first).

Note: this is a very very short overview of the math behind this. If you're working in some sort of 3D modelling software like Unity, all of this math will be implemented for you, most likely in a quaternion library. Searching for "quaternion rotation" will get you more details.

Draconis
  • 1,443
0

Wiki Rotation matrix has a lot of information on rotating around X, Y, Z separately by $\alpha, \beta, \gamma$. These matrices can be multiplied together to get more complex rotations, but you will need to know how many rads to rotate around each axis.

And finally a rotation matrix that takes a vector and theta to create and can rotate a point/Vector around it. (I would like to know how this is Matrix is developed)

Rotation Matrix given Unit vector to rotate around and Theta

You will need to set up the rotation matrix $R$ and multiply $a' = Ra , b' = Rb , c' = Rc$. Use trial and error to figure +/- Theta to get clockwise rotation (This may depend on the "camera" orientation).

My own example on KA Shows a gray vector rotating around a red vector. Both are focused at the origin, so it creates a cone like shape.

0

Computationally, rather than using rotation matrices to alter the axes, it is easier to find the components of the vectors $a$, $b$ and $c$ orthogonal (perpendicular) to the vector you want to rotate them about, and then directly compute the rotated vectors. I'm going to demonstrate how to do this with your vector $a$.

To find the components of vector $a$ orthogonal to a vector $v$, subtract $\hat va\cdot \hat v$ from $a$, where $\hat v=v/|v|$ is a unit vector in the direction of $v$. In this case $|v|^2=3$ so $\hat v=1/\sqrt3(1,1,1)$, and the part of $a$ orthogonal to $v$, $$a_{\bot}=(1,0,0)-\frac1{\sqrt3}\hat v\\ ={1\over3}(2,-1,-1),$$ and the part parallel to $\hat v$, $a_{\parallel}=1/3(1,1,1)$. Then we also need one other vector, the vector orthogonal to both $v$ and $a_{\bot}$ with the same magnitude as $a_{\bot}$, $$\hat v\times a_{\bot}\equiv a_{\times}={1\over\sqrt3}(0,-1,1).$$

Now $a$ rotated an angle $\theta$ around $v$, $$a_{\theta}=a_{\parallel}+a_{\bot}\cos\theta+a_{\times}\sin\theta.$$

Here is a computer demonstration rotating $a$ in the question by an angle $2\pi/3$.

package main

import ( "fmt" "math" )

type vec [3]float64

func (v vec) cross(w vec) (x vec) { x[0] = v[1]w[2] - v[2]w[1] x[1] = v[2]w[0] - v[0]w[2] x[2] = v[0]w[1] - v[1]w[0] return x } func (v vec) dot(w vec) (x float64) { x = v[0]w[0] + v[1]w[1] + v[2]w[2] return x } func (v vec) add(w vec) (x vec) { for i := 0; i < 3; i++ { x[i] = v[i] + w[i] } return x } func (v vec) mul(w float64) (x vec) { for i := 0; i < 3; i++ { x[i] = w v[i] } return x }

func (v vec) lsq() (x float64) { return v.dot(v) } func (v vec) l() (x float64) { return math.Sqrt(v.lsq()) } func main() { a := vec{1, 0, 0} v := vec{1, 1, 1} f := 1 / v.l() vdot := v.mul(f) apara := vdot.mul(a.dot(vdot)) aperp := a.add(apara.mul(-1)) across := aperp.cross(vdot) fmt.Printf("%v %v %v\n", apara, aperp, across) theta := 2 * math.Pi / 3 b := apara.add(aperp.mul(math.Cos(theta))) b = b.add(across.mul(math.Sin(theta))) fmt.Printf("%v\n", b) }

You can run it online here.

Suzu Hirose
  • 11,660