Quote Originally Posted by User137 View Post
I had this function in my old codes:...
Your code is perfectly fine. You don't need ABS in the last line though as ArcCos returns values from 0 to Pi. Values inside SQRT will never be negative as they are elevated to square. Detailed math is explained here. As you can see, your code does exactly that - the first part of code calculates dot product and second part divides it by multiplication of two vector lengths. P.S. if a>1 check was probably due to vectors not being of unitary length, which you should normalize instead.