0
$\begingroup$

I have a vector $v$ and two non-orthogonal vectors $p$ and $q$. I'm trying to decompose $v$ in terms of $p$ and $q$, resulting in two variables $i$ and $j$ such that $i~p + j~q = v$. After trying a few different things I settled on using the law of sines as follows (with $\cdot$ being the dot product of two vectors and $||v||$ being the length of $v$):

$x = \frac{||v||}{\sin (p \cdot q)}$

$i = \frac{x ~ \sin(q \cdot v)}{||p||}$

$j = \frac{x ~ \sin(v \cdot p)}{||q||}$

Unfortunately, this only gives me the absolute value of $i$ and $j$. For example, decomposing (6,0) in (0,1) and (3,2) produces 4 and 2, whereas the correct answer is -4 and 2. Can anyone tell me how to get the correct signs for $i$ and $j$?

  • 0
    @FalconNL: You're misusing the dot product. See [Wikipedia](http://en.wikipedia.org/wiki/Dot_product#Geometric_interpretation) for the *correct* angle formula.2011-07-26

1 Answers 1

1

We're obviously working in $\mathbb{R}^2$. Write $\vec{x}=(x_1,x_2)$, $\vec{p}=(p_1,p_2)$, $\vec{q}=(q_1,q_2)$. You want to solve for the coefficients in the following decomposition (which only works if $\vec{p}\not\|\vec{q}$, i.e. they aren't parallel so that they form a valid basis of $\mathbb{R}^2$):

$\vec{x} = a\vec{p}+b\vec{q}.$

We can write this in matrix form as follows:

$\begin{pmatrix} p_1 & q_1\\ p_2 & q_2 \end{pmatrix} \begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} x_1\\ x_2 \end{pmatrix}.$

Since the two basis vectors aren't parallel the determinant of the above matrix is nonzero, hence the matrix is nonsingular. So multiply both sides by the inverse matrix to solve for the coefficients:

$\begin{pmatrix} a \\ b \end{pmatrix} = \frac{1}{p_1q_2-p_2q_1}\begin{pmatrix} q_2 & -q_1\\ -p_2 & p_1 \end{pmatrix} \begin{pmatrix} x_1\\ x_2 \end{pmatrix}.$

Using the cross product and the vector $\vec{k}=(0,0,1)$, and interpreting all the original vectors as ones from the $xy$-plane of $\mathbb{R}^3$, we can then decompose $\vec{x}$ succinctly as

$\vec{x}=\left(\frac{(\vec{x}\times\vec{q})\cdot \vec{k}}{(\vec{p}\times\vec{q})\cdot\vec{k}} \right)\vec{p}+\left(\frac{(\vec{p}\times\vec{x})\cdot \vec{k}}{(\vec{p}\times\vec{q})\cdot\vec{k}}\right)\vec{q}.$

  • 0
    This works brilliantly, thanks.2011-07-26