# Rotation between two vectors as a function of time (one parameter rational motion design)

Given a time varying vector:

$\mathbf{w}(t) = \mathbf{u} + t\mathbf{v}$

I would like to find a rotation matrix $\mathbf{R}(t)$ that rotates the positive x-axis $[1, 0, 0]^T$ onto the vector $\mathbf{w}(t)$.

The resulting rotation matrix should be a function of $t$ only, and should contain only polynomials of $t$, not trigonometric functions of $t$. I believe this type of transform is called "one parameter rational motion design" in some fields.

I have tried to derive $\mathbf{R}(t)$ using quaternions (which is trivial for the case of rotating one static vector onto another), but expressing the rotation matrix as a function of the single variable $t$ is proving difficult.

Some more context: the overall goal is to define a quadric surface (in this case a cylinder) that is aligned with the time varying vector $\mathbf{w}(t)$. This has the form:

$\mathbf{x}^T\mathbf{R}\mathbf{A}\mathbf{R}^{-1}\mathbf{x}$ = 0

Where $\mathbf{A}$ defines the canonical quadric, and $\mathbf{R}(t)$ is the matrix sought, with $t \in [0, 1].$ When $\mathbf{x}$ is also a function of $t$, the result is a polynomial which can be solved for the time of intersection.

Let $\hat w$ be the unit vector in the direction of $w$, that is

$$\hat w = \frac{u+ tv}{\sqrt{u^2 + t^2 v^2 + 2 t u \cdot v}}$$

A little clifford algebra allows us to quickly derive the "quaternion" describing the rotation from $\hat x$ to $\hat w$ as a composition of reflections (or more directly, as reflection-inversions: reflections followed by inversions). First, we're going to reflect across the $yz$-plane and invert. This preserves the $\hat x$ direction. Then, we're going to reflect across the plane perpendicular to the angle bisector and invert. This maps $\hat x$ to $\hat w$.

All that remains is to calculate the angle bisector. Because $\hat x$ and $\hat w$ are equal in length, the angle bisector is just the sum: call it $\hat b$, so it's

$$\hat b = \frac{\hat x + \hat w}{\sqrt{2 + 2 \hat x \cdot \hat w}}$$

Then, the overall "quaternion" can be written as

$$q = \hat b \hat x = \frac{1 + \hat w \hat x}{\sqrt{2(1 + \hat x \cdot \hat w)}}$$

I'll assume you're unfamiliar with the geometric product here. You should note that the following equivalences between clifford algebra and traditional quaternion notation are true:

$$\hat x \hat y = -k, \quad \hat y \hat z = -i, \quad \hat z \hat x = -j$$

None of these products are commutative. On the other hand, the following are:

$$\hat x \hat x = \hat y \hat y = \hat z \hat z = +1$$

These should get you all you need to evaluate the above expressions, which should generate a quaternion that is a function of $t$ with no explicit trig functions (only radicals).

If we let $\mathbf{x} = (1,0,0)^T$ denote a unit vector along the $x$-axis, then a suitable rotation matrix $\mathbf{R}$ is the one whose columns are $$\frac{\mathbf{w}}{\|\mathbf{w}\|} \quad ; \quad \frac{\mathbf{w} \times \mathbf{x} }{\| \mathbf{w} \times \mathbf{x} \| } \times \frac{\mathbf{w}}{\|\mathbf{w}\|} \quad ; \quad \frac{\mathbf{w} \times \mathbf{x} }{\| \mathbf{w} \times \mathbf{x} \| }$$

This works only when $\| \mathbf{w} \times \mathbf{x} \| \ne 0$, of course.

As you can see if you work through the matrix multiplication calculations $\mathbf{y} = \mathbf{R}\mathbf{x}$, the key point is that the first column is $\mathbf{w} / \|\mathbf{w}\|$. The other columns can be anything you like as long as the three column vectors are mutually orthogonal and have unit length.

I'm not sure if this satisfies your requirements. It doesn't involve any trig functions, but it does include radicals, so it is not entirely polynomials. In fact, I think it's impossible to obtain formulae that involve polynomials alone. If I'm wrong, I'd very much like to see the solution.