Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gravitino committed Mar 6, 2015
1 parent 1997686 commit bd688b3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 35 deletions.
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CC = g++
FLAGS = -std=c++11 -O3 -Wall -mavx
FLAGS = -std=c++11 -O3 -Wall

all: testit fasttestit
all: testit fasttestit blending

testit: main.cpp dualquat.hpp
$(CC) $(FLAGS) main.cpp -o testit
Expand All @@ -11,5 +11,9 @@ fasttestit: main.cpp dualquat.hpp
$(CC) $(FLAGS) main.cpp -o fasttestit -march=native -Ofast
time ./fasttestit

blending: blending.cpp dualquat.hpp
$(CC) $(FLAGS) blending.cpp -o blending
time ./blending

clean:
rm -rf testit fasttestit
rm -rf testit fasttestit blending
File renamed without changes.
41 changes: 12 additions & 29 deletions dualquat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,6 @@ struct quat {
return difference.dot(difference);
}

value_t baddist (const quat<value_t>& other) const {

const bool I_know_what_I_do = false;
assert(I_know_what_I_do);

if (dot(other) < 0.0) {
const auto& difference = log()-(other*(-1.0)).log();
return difference.dot(difference);
}

const auto& difference = log()-other.log();
return difference.dot(difference);
}

bool isunit () const {
const value_t residue = w*w+x*x+y*y+z*z-1.0;
return residue*residue < EPS(value_t);
Expand Down Expand Up @@ -384,6 +370,18 @@ struct dualquat {
return generator.dot(generator);
}

value_t kinnorm () const {
const auto& Omega = real().log();
const auto& Veloc = dual()^real().C();
return Omega.dot(Omega)+Veloc.dot(Veloc);
}

value_t kilnorm () const {
const auto& Omega = real().log();
const auto& Veloc = dual()^real().C();
return Omega.dot(Omega)+2*Veloc.dot(Omega);
}

value_t eucdist (const dualquat<value_t>& other) const {

// TODO: could still be errornous
Expand All @@ -401,21 +399,6 @@ struct dualquat {
return difference.dot(difference);
}

value_t baddist (const dualquat<value_t>& other) const {

const bool I_know_what_I_do = true;
assert(I_know_what_I_do);

// TODO: could still be errornous
if (dot(other) < 0.0) {
const auto& difference = log()-(other*(-1.0)).log();
return difference.dot(difference);
}

const auto& difference = log()-other.log();
return difference.dot(difference);
}

bool isunit() const {

const value_t residue0 = w*w+x*x+y*y+z*z-1.0;
Expand Down
5 changes: 2 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ int main () {
}

const double eucdist = Q.eucdist(Q*(-1.0)),
logdist = Q.logdist(Q*(-1.0)),
baddist = Q.logdist(Q*(-1.0));
logdist = Q.logdist(Q*(-1.0));

if (eucdist > THRESHOLD || logdist > THRESHOLD || baddist > THRESHOLD)
if (eucdist > THRESHOLD || logdist > THRESHOLD)
std::cout << "distances: " << eucdist << ", " << logdist << std::endl;

}
Expand Down

0 comments on commit bd688b3

Please sign in to comment.