Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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

share|improve this question
    
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

1 Answer 1

up vote 1 down vote accepted

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.

In your case you get:

$$\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$.

share|improve this answer
    
Thanks for the help Calle, that did it. One issue I am still having, unrelated to this question directly, is that for a given arc transformation, with say x1= 45, y1 = 990, x2 = 95, y2 = 965, rx = 25, ry = 25, theta = -30, fA = 0, fS = 1, I am running into issues at figure 6.5.2 in that the calculation under the square root symbol evaluates to a negative number, meaning the calculation of cx' and cy' fails... any advice? –  Paul Mennega Feb 2 '11 at 20:12
    
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
    
Of course, yes that was the issue. Choosing rx, ry as less than half the Euclidean distance between the points is impossible... which is what those numbers describe. Trying valid numbers and it all works, thanks! –  Paul Mennega Feb 2 '11 at 20:49
    
Great! Good luck with your project! –  Calle Feb 2 '11 at 20:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.