Collaborative collection of useful userRPL snippets
|
03-26-2018, 08:32 AM
Post: #9
|
|||
|
|||
RE: Collaborative collection of useful userRPL snippets
I just had a quick look and noticed that the angle between vectors snippet is using the arccosine of the dot product. This has some numeric issues. Better is this formula:
\[angle\_between(\,\vec v_1, \vec v_2) = \begin{cases} \pi - 2 \, arcsin \frac{\mathopen|-\vec v_2 - \vec v_1\mathclose|}{2}, &\quad \vec v_1 \boldsymbol{\cdot} \vec v_2 < 0 \\ 2 \, arcsin \frac{\mathopen|\,\vec v_2 - \vec v_1\mathclose|}{2}, &\quad\text{otherwise.} \\ \end{cases} \] |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)