2
$\begingroup$

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

  • 0
    The angle operator isn't applied to a matrix, it's applied to two vectors.2011-02-02
  • 0
    Right, sorry, it's been about 15 years since I tackled this stuff, thanks!2011-02-02

1 Answers 1

1

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

  • 0
    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?2011-02-02
  • 0
    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?2011-02-02
  • 0
    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!2011-02-02
  • 0
    Great! Good luck with your project!2011-02-02