bcserv/smlib — pull request #12 by TheMadSword (2012-12-30 18:57:32+00:00)
Title: Optimizations surrounding the uses of GetVectorDistance + one clarification

Hi there,

I saw that you use GetVectorDistance without the third arg as true. Doing so make the computer calculate the real distance, which as you know would be calculated like :

SQUARE_ROOT(X^2 + Y^2 + Z^2)

The problem comes from the fact that the square root function is being expensive (like a sin or cos; it does iterate many time). Since you always use the calculated distance for comparison purpose, and that you don't need to return the distance itself, you should use its squared form.

Beside that, I saw your definition of "tolerance" for the "Math_VectorsEqual" function, and it was really, really unclear. I thought at first it was a % comparable to the length of the vectors themselves, so I did clarify that in the function description.

Red