Bläddra i källkod

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

legacy
Sam Hocevar sam 12 år sedan
förälder
incheckning
4770daf4ac
2 ändrade filer med 12 tillägg och 12 borttagningar
  1. +7
    -7
      src/lol/math/vector.h
  2. +5
    -5
      test/tutorial/03_fractal.cpp

+ 7
- 7
src/lol/math/vector.h Visa fil

@@ -268,7 +268,7 @@ template <typename T> struct Cmplx
return Cmplx<T>(x, -y);
}

inline T norm() const { return len(*this); }
inline T norm() const { return length(*this); }
#if !defined __ANDROID__
template<typename U>
friend std::ostream &operator<<(std::ostream &stream, Cmplx<U> const &v);
@@ -280,7 +280,7 @@ template <typename T> struct Cmplx
template<typename T>
static inline Cmplx<T> re(Cmplx<T> const &val)
{
return ~val / sqlen(val);
return ~val / sqlength(val);
}

template<typename T>
@@ -1002,7 +1002,7 @@ template <typename T> struct Quat
template<typename T>
inline T norm(Quat<T> const &val)
{
return sqlen(val);
return sqlength(val);
}

template<typename T>
@@ -1187,7 +1187,7 @@ static inline Quat<T> operator /(Quat<T> x, Quat<T> const &y)
} \
\
tprefix \
inline type sqlen(tname<type> const &a) \
inline type sqlength(tname<type> const &a) \
{ \
type acc = 0; \
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 \
inline double len(tname<type> const &a) \
inline double length(tname<type> const &a) \
{ \
using std::sqrt; \
return sqrt((double)sqlen(a)); \
return sqrt((double)sqlength(a)); \
} \
\
tprefix \
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; \
}



+ 5
- 5
test/tutorial/03_fractal.cpp Visa fil

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

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)
n = maxsqlen * maxsqlen;


Laddar…
Avbryt
Spara