Browse Source

math: replace len(vec) with length(vec) to match the GLSL naming.

legacy
Sam Hocevar sam 12 years ago
parent
commit
4770daf4ac
2 changed files with 12 additions and 12 deletions
  1. +7
    -7
      src/lol/math/vector.h
  2. +5
    -5
      test/tutorial/03_fractal.cpp

+ 7
- 7
src/lol/math/vector.h View File

@@ -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; \
} }




+ 5
- 5
test/tutorial/03_fractal.cpp View File

@@ -383,7 +383,7 @@ public:
z2 = z1 * z1 + r0; z2 = z1 * z1 + r0;
z3 = z2 * z2 + r0; z3 = z2 * z2 + r0;
z0 = z3 * z3 + r0; z0 = z3 * z3 + r0;
if (sqlen(z0) >= maxsqlen)
if (sqlength(z0) >= maxsqlen)
break; break;
iter -= 4; iter -= 4;
if (iter < 4) if (iter < 4)
@@ -392,11 +392,11 @@ public:


if (iter) if (iter)
{ {
double n = sqlen(z0);
double n = sqlength(z0);


if (sqlen(z1) >= maxsqlen) { iter += 3; n = sqlen(z1); }
else if (sqlen(z2) >= maxsqlen) { iter += 2; n = sqlen(z2); }
else if (sqlen(z3) >= maxsqlen) { iter += 1; n = sqlen(z3); }
if (sqlength(z1) >= maxsqlen) { iter += 3; n = sqlength(z1); }
else if (sqlength(z2) >= maxsqlen) { iter += 2; n = sqlength(z2); }
else if (sqlength(z3) >= maxsqlen) { iter += 1; n = sqlength(z3); }


if (n > maxsqlen * maxsqlen) if (n > maxsqlen * maxsqlen)
n = maxsqlen * maxsqlen; n = maxsqlen * maxsqlen;


Loading…
Cancel
Save