3D Animation of object flying straight towards a surface

157 Views Asked by At

Lets say we have the following the orthogonal(?) 4x4 matrix, which represents a world space transformation in a right-handed coordinate system.

$$W=\begin{bmatrix}100&0&0&0\\0&100&0&0\\0&0&100&0\\0&0&0&1\end{bmatrix}$$

Next, we add an arbitrary position vector of an object $p$ along with its facing direction vector $v$, both of which are transformed relative to $W$.

$$p=\begin{bmatrix}p_x\\p_y\\p_z\\1\end{bmatrix} \to p'=Wp$$ $$v=\begin{bmatrix}v_x\\v_y\\v_z\\0\end{bmatrix} \to v'=Wv$$

Now we can introduce the matrix $S$, which represents the local object space of an arbitrary surface (e.g., a wall), along with $n$ - the surface normal of the surface represented by $S$:

$$n = \begin{bmatrix}n_x\\n_y\\n_z\\0\end{bmatrix}$$

Then we introduce two new transformations $s_n$ and $s_p$, which represent $S$'s surface normal and the location (i.e., destination) of $p$ once $p$ has hit the surface.

Thus,

$$s_n=WSn$$ $$s_p=WSp$$

So, the goal here is to take the position denoted by $p'$ (relative to our world-space transform) and push its object towards an arbitrary surface, with the end result being the translation of $s_p$.

Since the direction of $p$ is arbitrary and denoted by $v$, it makes sense to create a direction from $v$ relative to $n$ by computing their difference (relative to $W$):

$$v_{wn} = W(v'-s_n)$$

which leads to,

$$p_{d} = p' + v_{wn}$$

This smells of linear interpolation along $p_{d} - s_p$ - or rather, the directional axis between $p_d$ and $s_p$ (in case I don't have that correctly).

Thus, I'm thinking we can define a scalar $t$ which exists within the range $[0...1]$. So we can define a function $f(t)$ to do this:

$$p_t = f(t) = p_{d} - t(s_p)$$

Where $p_t$ is the current location of the object as its flying toward our destination surface.

I know this is a lot of information...what I'm really looking for here is validation - am I correct in these assumptions? If not, what exactly is wrong?

I really appreciate any feed back on this.