# How do I calculate theta, given the linked formula?

My algebra books are in storage and Google is not being helpful...

In figure 6.5.5, how do I apply the angle operator to the matrix columns to determine a value for theta?

http://www.w3.org/TR/SVG/implnote.html#ArcImplementationNotes

Thanks for any pointers,

Paul

-
The angle operator isn't applied to a matrix, it's applied to two vectors. – Calle Feb 2 '11 at 16:59
Right, sorry, it's been about 15 years since I tackled this stuff, thanks! – Paul Mennega Feb 2 '11 at 19:08

Well, it's the angle between two vectors, in this case the vectors

$$\begin{pmatrix} 1 \\ 0 \end{pmatrix} ~~ \textrm{and} ~~ \begin{pmatrix} \frac{x_1 - c_x}{r_x} \\ \frac{y_1 - c_y}{r_y} \end{pmatrix}$$

In general, if you have two real vectors $v_1$ and $v_2$, and want to calculate the angle between them, use the scalar product, $\langle v_1, v_2 \rangle = v_2^T v_1$ and the formula

$$\langle v_1, v_2 \rangle = \|v_1\| \|v_2\| \cos \theta$$

where $\theta$ is the angle. This gives you:

$$\cos \theta = \frac{v_2^T v_1}{\|v_1\| \|v_2\|} = \frac{\sum_{i = 1}^n v^1_i v^2_i}{\|v_1\| \|v_\|}$$

where $v^1_i$ and $v^2_i$ are the components at position $i$ of the vectors $v_1$ and $v_2$ respectively.

$$\cos \theta = \frac{\frac{x_1-c_x}{r_x}}{\sqrt{\left( \frac{x_1 - c_x}{r_x} \right)^2 + \left( \frac{y_1 - c_y}{r_y} \right)^2}}$$
use $\arccos$ to get a value for $\theta$.
Glad I could help! I get a negative number too. I guess you mean that $\phi = -30$, not $\theta$? I haven't really looked into what it is all about, but are you sure that these values are realistic (that is, would they really arise in your implementation)? If yes, are complex numbers out of the question? – Calle Feb 2 '11 at 20:43