Skip to content

Commit

Permalink
removed geeky stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitino committed Mar 4, 2015
1 parent 8bed2ef commit 8e9edb7
Showing 1 changed file with 4 additions and 22 deletions.
26 changes: 4 additions & 22 deletions dualquat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,10 @@
#include <limits>
#include <cmath>

#include <immintrin.h>
#include <assert.h>

#define EPS(value_t) (std::numeric_limits<value_t>::epsilon())

template <class value_t>
inline value_t rsqrt(value_t x) {
return 1.0/std::sqrt(x);
}

/* feel free to substitute AVX variants
template <>
inline float rsqrt(float x) {
return 1.0/std::sqrt(x);
}
template <>
inline double rsqrt(double x) {
return 1.0/std::sqrt(x);
}
*/

template <class value_t>
struct quat {

Expand Down Expand Up @@ -89,7 +71,7 @@ struct quat {
}

quat<value_t> N() const {
const value_t rho = sqrt(w*w+x*x+y*y+z*z);
const value_t rho = std::sqrt(w*w+x*x+y*y+z*z);
return quat<value_t>(w/rho, x/rho, y/rho, z/rho);
}

Expand Down Expand Up @@ -130,7 +112,7 @@ struct quat {

assert(isunit());

const value_t inv = rsqrt(x*x+y*y+z*z+EPS(value_t));
const value_t inv = 1.0/std::sqrt(x*x+y*y+z*z+EPS(value_t));
const value_t fac = std::acos(w > 1 ? 1 : w < -1 ? -1 : w)*inv;

return quat<value_t> (0, x*fac, y*fac, z*fac);
Expand Down Expand Up @@ -284,7 +266,7 @@ struct dualquat {
const value_t qq = w*w+x*x+y*y+z*z+EPS(value_t);
const value_t qQ = w*W+x*X+y*Y+z*Z;
const value_t invqq = 1.0/qq;
const value_t invsq = rsqrt(qq);
const value_t invsq = 1.0/std::sqrt(qq);
const value_t alpha = qQ*invqq*invqq;

return dualquat<value_t>(w*invsq, x*invsq,
Expand Down Expand Up @@ -365,7 +347,7 @@ struct dualquat {
assert(isunit());

const value_t theta = 2.0*std::acos(w > 1 ? 1 : w < -1 ? -1 : w);
const value_t invvv = 0.5*rsqrt(x*x+y*y+z*z+EPS(value_t));
const value_t invvv = 0.5/std::sqrt(x*x+y*y+z*z+EPS(value_t));
const value_t pitch = -4.0*W*invvv;
const value_t alpha = pitch*w;

Expand Down

0 comments on commit 8e9edb7

Please sign in to comment.