0
$\begingroup$

I've got a plane in a 3D space (triangle, represented by 2 direction vectors a and b) and a vertex on the plane (v).

$\boldsymbol{a}$, $\boldsymbol{b}$ and $\boldsymbol{v}$ are vectors, $s$ and $t$ are scalars $$\boldsymbol{v} = s \, \boldsymbol{a} + t \, \boldsymbol{b}$$

$a = (a_x, a_y, a_z)$ etc.

$$v_x = s \, a_x + t \, b_x$$ $$ v_y = s \, a_y + t \, b_y$$ $$ v_z = s \, a_z + t \, b_z$$

I know a, b and v. And v is definitelly on the plane. I need to find the scalar-factors s and t. When I try to solve this I get something like

$$\begin{align}t &=& \frac{v_z - v_x \frac{ a_z }{ a_x} }{ b_z - b_x \frac{ a_z }{ a_x}}\\ s &=& \frac{v_x - t \, b_x }{ a_x} \end{align}$$

and other variations. And it seems to give me good results many times, but not always.

Problem:
Sometimes I get for $2$ different $v$ the very same values for $s$ and $t$. I expect each new vertex of the triangle to have a unique pair of $s$ and $t$.

I know I have too few unknown variables. What I don't understand just now: what does it mean for my results? What can I do to improve my procedure of solving this equation?

3 Answers 3

1

If you have the same values for $s$ and $t$ for different $v$, one of the $v$ cannot be on the plane.

In order to improve your procedure, I would recommend to introduce a third vector $c$ which is the cross product of $a$ and $b$, i.e. $c=a\times b$. Then try to solve $$ v_x = a_xs+b_xt+c_xu \\ v_y = a_ys+b_yt+c_yu \\ v_z = a_zs+b_zt+c_zu $$ If $a$ and $b$ actually span a plane (not only a line), then this system has always a unique solution. If $u=0$ then you can be sure that $v$ is on the plane and $s$ and $t$ are the desired results. If $u\neq 0$, then $v$ is not on the plane.

Use Cramer's rule and the Rule of Sarrus, if you want to have a closed-form expression for the solution.

Alternatively, multiply the first of your equations with $a_x$, the second with $a_y$ and the third with $a_z$ and take the sum of the results. Then do the same with $b_x$, $b_y$ and $b_z$. You will get two new equations: $$ (a^{2}_{x}+a^{2}_{y}+a^{2}_{z})s + (a_xb_x+a_yb_y+a_zb_z)t = (a_xv_x+a_yv_y+a_zv_z) \\ (a_xb_x+a_yb_y+a_zb_z)s + (b^{2}_{x}+b^{2}_{y}+b^{2}_{z})t = (b_xv_x+b_yv_y+b_zv_z) $$ If $a$ and $b$ span a plane, this system of equations is always solvable without distinction of cases.

  • 0
    Sounds like a good idea with the cross product vector. Thanks.2017-01-20
  • 0
    I've used the first part of your answer. After solving and optimizing I get flawless results now. And since I **know** v is on the plane and (u=0). I can eliminate c and u.2017-01-31
0

If you have two linear independent vectors $a$, $b$ in $\mathbb{R}^3$ they indeed span a plane: $$ H = \langle a, b \rangle = \{ v = s a + t b \mid s, t \in \mathbb{R} \} $$ The scalar coefficients $s$ and $t$ can be interpreted as coordinates regarding the base vectors $a$ and $b$.

You have $a$, $b$ and want to recover $s$ and $t$ for a given $v \in H$. So we have $$ v = s a + t b $$ which in matrix form can be written as $$ \begin{pmatrix} a_1 & b_1 \\ a_2 & b_2 \\ a_3 & b_3 \\ \end{pmatrix} \begin{pmatrix} s \\ t \end{pmatrix} = \begin{pmatrix} v_1 \\ v_2 \\ v_2 \end{pmatrix} \quad (*) $$ In general $(*)$ is an inhomogeneous linear system $Ax = v$.

While the matrix $A$ has three rows, only two of them can be linear independent, as the generated plane is a two-dimensional subspace of $\mathbb{R}$. It depends on the specific choice of $a$ and $b$ which two of the three rows are linear independent ones. Your given formula

$$\begin{align}t &= \frac{v_z - v_x \frac{ a_z }{ a_x} }{ b_z - b_x \frac{ a_z }{ a_x}}\\ s &= \frac{v_x - t \, b_x }{ a_x} \end{align}$$

will only work for the special case where $a_x \ne 0$. It will not handle the case $a = (0,1,0)^T, b=(0,0,1)^T$. That is why one has to use a more flexible method to solve the system.

We can use the following short hand notation for the system $(*)$: $$ [A\mid v] = \left[ \begin{array}{rr|r} a_1 & b_1 & v_1 \\ a_2 & b_2 & v_2 \\ a_3 & b_3 & v_3 \end{array} \right] $$ On this augmented matrix we perform a Gauss-Jordan elimination, using a couple of elementary row operations. This will result in a augmented matrix in reduced row echelon form: $$ \left[ \begin{array}{rr|r} 1 & 0 & s \\ 0 & 1 & t \\ 0 & 0 & 0 \end{array} \right] $$ It allows to read the solution from this matrix. In practice the finite representation of real numbers might introduce errors. This is the subject of numerical mathematics.

Sometimes I get for 2 different v the very same values for s and t. I expect each new vertex of the triangle to have a unique pair of s and t.

This indicates an error in your solver. The coordinates $s$ and $t$ are unique for a basis $a$, $b$ of the plane.

  • 0
    I know about the (ax != 0). That's why I have other variations for my formulas. I haven't heard about "Gaussian elimination" yet. Is it worth learning it to solve those equations?2017-01-20
  • 0
    Absolutely. It is the standard method for solving systems of linear equations manually, and it is also implemented in some software applications. But it is not suitable if you want to have the result as a closed-form expression, because it still requires distinction of cases, e.g. in order to decide if rows must be swapped or not.2017-01-20
  • 0
    You should try a few examples. It consists of searching non-zero elements, multiplying a row with a number, exchanging rows and adding a scalar multiple row to another row. Done right it will yield the above transformed system. It need less operations than the explicit formulas.2017-01-20
0

If your vectors $a$, $b$ and $v$ are coplanar, than $v$ is a unique linear representation of vectors $a$ and $b$ if and only if your vectors $a$ and $b$ are not collinear.

So if your vectors $a$ and $b$ are not parallel you should always have a unique solution $(s,t)$, while if they are parallel that would make the system either have no solutions (if your vector $v$ is not parallel to $a$ and $b$) or infintelly many (if vector $v$ is parallel to vectors $a$ and $b$).

Basically what you need to ensure, is that your vectors $a$ and $b$ are not multiples of each other (so that would mean, they are not parallel to each other, or they actually span a plain not just a line).

Edit: The other problem may be, that if you got two different $v_1$ and $v_2$ for the same $(s,t)$ you should just check in the end, which one of those two actually equals $sa+tb$. The other one probably just does not lie on the plain.