Commit 5e52431b authored by Jan Möbius's avatar Jan Möbius
Browse files

new operator to access dual quaternion elements sequentially



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@15487 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 317ea08c
......@@ -205,15 +205,16 @@ namespace ACG {
template <typename Scalar>
void DualQuaternionT<Scalar>::normalize() {
double magn = 1.0/real_.norm();
double magnSqr = 1.0/real_.sqrnorm();
const double magn = 1.0/real_.norm();
const double magnSqr = 1.0/real_.sqrnorm();
//normalize rotation
// normalize rotation
real_ *= magn;
dual_ *= magn;
//normalize the rest
// normalize the rest
dual_ -= ((real_| dual_)* magnSqr) * real_;
}
//-----------------------------------------------------------------------------
......@@ -302,6 +303,22 @@ namespace ACG {
return q;
}
//-----------------------------------------------------------------------------
template <typename Scalar>
Scalar& DualQuaternionT<Scalar>::operator [](const unsigned int& b) {
if ( b < 4 ) {
return real_[b];
} else if ( b < 8 ) {
return dual_[b - 4];
} else {
// Invalid operation, write error and return anything.
std::cerr << "Error in Dualquaternion operator[], index b out of range [0...7]" << std::endl;
return real_[0];
}
}
//-----------------------------------------------------------------------------
/// linear interpolation of dual quaternions. Result is normalized afterwards.
......
......@@ -164,6 +164,9 @@ public:
/// dualQuaternion *= dualQuaternion
DualQuaternion& operator*=(const DualQuaternion& _q);
/// Access as one big vector
Scalar& operator [](const unsigned int& b);
/// linear interpolation of dual quaternions. Result is normalized afterwards
static DualQuaternion interpolate(std::vector<double>& _weights, const std::vector<DualQuaternion>& _dualQuaternions);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment