Skip to content
Snippets Groups Projects
Commit ebd5282a authored by Oliver Sander's avatar Oliver Sander Committed by sander@PCPOOL.MI.FU-BERLIN.DE
Browse files

use method difference() throughout and make that method a bit more stable

[[Imported from SVN: r1637]]
parent abf30972
No related branches found
No related tags found
No related merge requests found
...@@ -254,15 +254,23 @@ public: ...@@ -254,15 +254,23 @@ public:
// Compute the geodesical distance between a and b on SO(3) // Compute the geodesical distance between a and b on SO(3)
// Due to numerical dirt, diff[3] may be larger than 1. // Due to numerical dirt, diff[3] may be larger than 1.
// In that case, use 1 instead of diff[3]. // In that case, use 1 instead of diff[3].
T dist = 2*std::acos( std::min(diff[3],1.0) ); Dune::FieldVector<T,3> v;
if (diff[3] > 1.0) {
T invSinc = 1/sincHalf(dist); v = 0;
// Compute difference on T_a SO(3) } else {
Dune::FieldVector<T,3> v;
v[0] = diff[0] * invSinc; T dist = 2*std::acos( std::min(diff[3],1.0) );
v[1] = diff[1] * invSinc;
v[2] = diff[2] * invSinc; T invSinc = 1/sincHalf(dist);
// Compute difference on T_a SO(3)
v[0] = diff[0] * invSinc;
v[1] = diff[1] * invSinc;
v[2] = diff[2] * invSinc;
}
return v; return v;
} }
...@@ -271,24 +279,8 @@ public: ...@@ -271,24 +279,8 @@ public:
/** \todo Use method 'difference' here */ /** \todo Use method 'difference' here */
static Quaternion<T> interpolate(const Quaternion<T>& a, const Quaternion<T>& b, double omega) { static Quaternion<T> interpolate(const Quaternion<T>& a, const Quaternion<T>& b, double omega) {
// Interpolation on the geodesic in SO(3) from a to b
Quaternion<T> diff = a;
diff.invert();
diff = diff.mult(b);
// Compute the geodesical distance between a and b on SO(3)
// Due to numerical dirt, diff[3] may be larger than 1.
// In that case, use 1 instead of diff[3].
T dist = 2*std::acos( std::min(diff[3],1.0) );
T invSinc = 1/sincHalf(dist);
// Compute difference on T_a SO(3) // Compute difference on T_a SO(3)
Dune::FieldVector<T,3> v; Dune::FieldVector<T,3> v = difference(a,b);
v[0] = diff[0] * invSinc;
v[1] = diff[1] * invSinc;
v[2] = diff[2] * invSinc;
v *= omega; v *= omega;
...@@ -300,25 +292,9 @@ public: ...@@ -300,25 +292,9 @@ public:
static Quaternion<T> interpolateDerivative(const Quaternion<T>& a, const Quaternion<T>& b, static Quaternion<T> interpolateDerivative(const Quaternion<T>& a, const Quaternion<T>& b,
double omega, double intervallLength) { double omega, double intervallLength) {
Quaternion<T> result; Quaternion<T> result;
// Interpolation on the geodesic in SO(3) from a to b
// diff = a^-1 b
Quaternion<T> diff = a;
diff.invert();
diff = diff.mult(b);
// Compute the geodesical distance between a and b on SO(3)
// Due to numerical dirt, diff[3] may be larger than 1.
// In that case, use 1 instead of diff[3].
T dist = 2*std::acos( std::min(diff[3],1.0) );
T invSinc = 1/sincHalf(dist);
// Compute difference on T_a SO(3) // Compute difference on T_a SO(3)
Dune::FieldVector<double,3> v; Dune::FieldVector<double,3> v = difference(a,b);
v[0] = diff[0] * invSinc;
v[1] = diff[1] * invSinc;
v[2] = diff[2] * invSinc;
Dune::FieldVector<double,3> der = v; Dune::FieldVector<double,3> der = v;
der /= intervallLength; der /= intervallLength;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment