Skip to content
Snippets Groups Projects
Commit 688a1524 authored by marco's avatar marco
Browse files

fix broken *= operator of quat

git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2421 5a81b35b-ba03-0410-adc8-b2c5c5119f08
parent a38fd816
No related branches found
No related tags found
No related merge requests found
...@@ -317,10 +317,19 @@ Quat& Quat::operator*=(Real s) ...@@ -317,10 +317,19 @@ Quat& Quat::operator*=(Real s)
Quat& Quat::operator*=(const Quat& q) Quat& Quat::operator*=(const Quat& q)
{ {
w = this->w*q.w - this->x*q.x - this->y*q.y - this->z*q.z; Vec3 v00 (x,y,z);
x = this->w*q.x + this->x*q.w + this->y*q.z - this->z*q.y; Vec3 v10 (q.x,q.y,q.z);
y = this->w*q.y + this->y*q.w - this->x*q.z + this->z*q.x;
z = this->w*q.z + this->z*q.w + this->x*q.y - this->y*q.x; Real w2=w*q.w-Dot(v00,v10);
Vec3 v2=Cross(v00,v10);
Vec3 v3=v10; v3 *= w;
Vec3 v4=v00; v4 *= q.w;
Vec3 v5=v2+v3+v4;
w=w2;
x=v5[0];
y=v5[1];
z=v5[2];
return *this; return *this;
} }
...@@ -447,6 +456,7 @@ Vec3 Quat::Rotate(const Vec3& vec) const { ...@@ -447,6 +456,7 @@ Vec3 Quat::Rotate(const Vec3& vec) const {
Quat tmp(0.0, vec[0], vec[1], vec[2]); Quat tmp(0.0, vec[0], vec[1], vec[2]);
Quat conj=Conjugate(*this); Quat conj=Conjugate(*this);
Quat res=*this*tmp*conj; Quat res=*this*tmp*conj;
std::cout << *this << "*" << tmp << "*" << conj << std::endl;
return Vec3(res.x, res.y, res.z); return Vec3(res.x, res.y, res.z);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment