| 668 | } |
| 669 | |
| 670 | inline double normalize3(const vec* pDefaultVec = NULL) |
| 671 | { |
| 672 | static_assert(N >= 3); |
| 673 | |
| 674 | double n = m_s[0] * m_s[0] + m_s[1] * m_s[1] + m_s[2] * m_s[2]; |
| 675 | |
| 676 | if (n != 0) |
| 677 | *this *= static_cast<T>((1.0f / sqrt(n))); |
| 678 | else if (pDefaultVec) |
| 679 | *this = *pDefaultVec; |
| 680 | return n; |
| 681 | } |
| 682 | |
| 683 | inline vec& normalize_in_place(const vec* pDefaultVec = NULL) |
| 684 | { |