|
@@ -268,7 +268,7 @@ template <typename T> struct Cmplx |
|
|
return Cmplx<T>(x, -y); |
|
|
return Cmplx<T>(x, -y); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
inline T norm() const { return len(*this); } |
|
|
|
|
|
|
|
|
inline T norm() const { return length(*this); } |
|
|
#if !defined __ANDROID__ |
|
|
#if !defined __ANDROID__ |
|
|
template<typename U> |
|
|
template<typename U> |
|
|
friend std::ostream &operator<<(std::ostream &stream, Cmplx<U> const &v); |
|
|
friend std::ostream &operator<<(std::ostream &stream, Cmplx<U> const &v); |
|
@@ -280,7 +280,7 @@ template <typename T> struct Cmplx |
|
|
template<typename T> |
|
|
template<typename T> |
|
|
static inline Cmplx<T> re(Cmplx<T> const &val) |
|
|
static inline Cmplx<T> re(Cmplx<T> const &val) |
|
|
{ |
|
|
{ |
|
|
return ~val / sqlen(val); |
|
|
|
|
|
|
|
|
return ~val / sqlength(val); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> |
|
|
template<typename T> |
|
@@ -1002,7 +1002,7 @@ template <typename T> struct Quat |
|
|
template<typename T> |
|
|
template<typename T> |
|
|
inline T norm(Quat<T> const &val) |
|
|
inline T norm(Quat<T> const &val) |
|
|
{ |
|
|
{ |
|
|
return sqlen(val); |
|
|
|
|
|
|
|
|
return sqlength(val); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
template<typename T> |
|
|
template<typename T> |
|
@@ -1187,7 +1187,7 @@ static inline Quat<T> operator /(Quat<T> x, Quat<T> const &y) |
|
|
} \ |
|
|
} \ |
|
|
\ |
|
|
\ |
|
|
tprefix \ |
|
|
tprefix \ |
|
|
inline type sqlen(tname<type> const &a) \ |
|
|
|
|
|
|
|
|
inline type sqlength(tname<type> const &a) \ |
|
|
{ \ |
|
|
{ \ |
|
|
type acc = 0; \ |
|
|
type acc = 0; \ |
|
|
for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ |
|
|
for (size_t n = 0; n < sizeof(a) / sizeof(type); n++) \ |
|
@@ -1196,16 +1196,16 @@ static inline Quat<T> operator /(Quat<T> x, Quat<T> const &y) |
|
|
} \ |
|
|
} \ |
|
|
\ |
|
|
\ |
|
|
tprefix \ |
|
|
tprefix \ |
|
|
inline double len(tname<type> const &a) \ |
|
|
|
|
|
|
|
|
inline double length(tname<type> const &a) \ |
|
|
{ \ |
|
|
{ \ |
|
|
using std::sqrt; \ |
|
|
using std::sqrt; \ |
|
|
return sqrt((double)sqlen(a)); \ |
|
|
|
|
|
|
|
|
return sqrt((double)sqlength(a)); \ |
|
|
} \ |
|
|
} \ |
|
|
\ |
|
|
\ |
|
|
tprefix \ |
|
|
tprefix \ |
|
|
inline tname<type> normalize(tname<type> const &val) \ |
|
|
inline tname<type> normalize(tname<type> const &val) \ |
|
|
{ \ |
|
|
{ \ |
|
|
type norm = (type)len(val); \ |
|
|
|
|
|
|
|
|
type norm = (type)length(val); \ |
|
|
return norm ? val / norm : val * (type)0; \ |
|
|
return norm ? val / norm : val * (type)0; \ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|