Commit ca12b223 authored by David Bommes's avatar David Bommes

- changed to template Vector function for rotate

- disabled matrix constructor
- added print_info function

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@9382 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 98086b1f
......@@ -112,10 +112,10 @@ public:
Z = sin_theta * _axis[2];
}
/// construct from rotation matrix (only valid for rotation matrices!)
template <class MatrixT>
QuaternionT(const MatrixT& _rot)
{ init_from_matrix( _rot); }
// /// construct from rotation matrix (only valid for rotation matrices!)
// template <class MatrixT>
// QuaternionT(const MatrixT& _rot)
// { init_from_matrix( _rot); }
/// identity rotation
......@@ -146,10 +146,11 @@ public:
/// rotate vector
Vec3 rotate(const Vec3& _v)
template <class Vec3T>
Vec3T rotate(const Vec3T& _v) const
{
Quaternion q = *this * Quaternion(_v) * conjugate();
return Vec3(q[1], q[2], q[3]);
Quaternion q = *this * Quaternion(0,_v[0],_v[1],_v[2]) * conjugate();
return Vec3T(q[1], q[2], q[3]);
}
......@@ -305,6 +306,22 @@ public:
return Quaternion( 0, n[0], n[1], n[2]);
}
void print_info()
{
// get axis, angle and matrix
Vec3 axis;
Scalar angle;
this->axis_angle( axis, angle);
Matrix m;
m = this->rotation_matrix();
std::cerr << "quaternion : " << (*this) << std::endl;
std::cerr << "length : " << this->norm() << std::endl;
std::cerr << "axis, angle: " << axis << ", " << angle*180.0/M_PI << "\n";
std::cerr << "rot matrix :\n";
std::cerr << m << std::endl;
}
#undef W
#undef X
......
Markdown is supported
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