Evaluating cotan - cmu462/Scotty3D GitHub Wiki

Given two vectors in ![height=14px](https://raw.githubusercontent.com/wiki/cmu462/Scotty3Dmedia/cotan_note/0000.png|height=16px]], media/cotan_note/0001.png and media/cotan_note/0002.png, how do we evaluate the cotangent of the angle [[media/cotan_note/0003.png) between these vectors?

We could do this explicitly, by using inverse trig functions to find the angle between the vectors, then taking the cotangent of that angle. However, with some derivation we can find an alternate approach, which is simpler, more efficient, and more numerically robust.

Of course, the cotangent is given by

height=41px

Recall that the dot product is given by ![height=19px](https://raw.githubusercontent.com/wiki/cmu462/Scotty3Dmedia/cotan_note/0005.png|height=19px]]. The magnitude of the cross product is given by media/cotan_note/0006.png. We can use these to evaluate [[media/cotan_note/0007.png)!

height=41px

This "dot over cross" expression is thus equivalent to the cotangent of the angle, yet does not require evaluating any trig functions. It also avoids having to normalize the vectors.