The choice between the two is mostly a matter of preference, and can sometimes be a matter of efficiency. If we normalize n we must compute a dot product and one sqrt. If we divide, we must compute a dot product and one division. Is division cheaper than sqrt? Probably! The point is by carefully crafting the code some operations can be avoided or changed without compromising the result. To do this we have to understand the dot product definition very well.

]]>
1 |
if ( dot( d, d ) < LENGTH * LENGTH ) { ... } |

Is equivalent to:

1 |
if ( sqrt( dot( d, d ) ) < LENGTH ) { ... } |

Does that make sense? Hope that helps!

Edit: OOPS. This seems not to be what you were looking for, please see my other answer :)

]]> Regardless, I *am* confused about the fact that **n** is not of unit length.