Add functions to return the squared length of a vector: Comparing two squared values prevents two computionally heavy sqrt calls.
This commit is contained in:
@@ -231,6 +231,14 @@ T
|
||||
norm(const SGVec2<T>& v)
|
||||
{ return simd4::magnitude(v.simd2()); }
|
||||
|
||||
/// The squared euclidean norm of the vector
|
||||
/// Comparing two squared values prevents two computionally heavy sqrt calls.
|
||||
template<typename T>
|
||||
inline
|
||||
T
|
||||
norm2(const SGVec2<T>& v)
|
||||
{ return simd4::magnitude2(v.simd2()); }
|
||||
|
||||
/// The euclidean norm of the vector, that is what most people call length
|
||||
template<typename T>
|
||||
inline
|
||||
|
||||
@@ -301,6 +301,15 @@ T
|
||||
norm(const SGVec3<T>& v)
|
||||
{ return simd4::magnitude(v.simd3()); }
|
||||
|
||||
/// The squared euclidean norm of the vector
|
||||
/// Comparing two squared values prevents two computionally heavy sqrt calls.
|
||||
template<typename T>
|
||||
inline
|
||||
T
|
||||
norm2(const SGVec3<T>& v)
|
||||
{ return simd4::magnitude2(v.simd3()); }
|
||||
|
||||
|
||||
/// The euclidean norm of the vector, that is what most people call length
|
||||
template<typename T>
|
||||
inline
|
||||
|
||||
@@ -249,6 +249,14 @@ T
|
||||
norm(const SGVec4<T>& v)
|
||||
{ return simd4::magnitude(v.simd4()); }
|
||||
|
||||
/// The squared euclidean norm of the vector
|
||||
/// Comparing two squared values prevents two computionally heavy sqrt calls.
|
||||
template<typename T>
|
||||
inline
|
||||
T
|
||||
norm2(const SGVec4<T>& v)
|
||||
{ return simd4::magnitude2(v.simd4()); }
|
||||
|
||||
/// The euclidean norm of the vector, that is what most people call length
|
||||
template<typename T>
|
||||
inline
|
||||
|
||||
Reference in New Issue
Block a user