CRelAngle division ops

This commit is contained in:
Phillip Stephens 2016-09-01 13:17:33 -07:00
parent 1bba8594d5
commit 8ccc52d3b1
2 changed files with 4 additions and 2 deletions

View File

@ -165,7 +165,7 @@ public:
*/ */
static inline CQuaternion fromAxisAngle(const CUnitVector3f& axis, const CRelAngle& angle) static inline CQuaternion fromAxisAngle(const CUnitVector3f& axis, const CRelAngle& angle)
{ {
return CQuaternion(std::cos(angle.asRadians() / 2.f), axis * std::sin(angle.asRadians() / 2.f)); return CQuaternion(std::cos(angle / 2.f), axis * std::sin(angle / 2.f));
} }
void rotateX(const CRelAngle& angle) { *this *= fromAxisAngle({1.0f, 0.0f, 0.0f}, angle); } void rotateX(const CRelAngle& angle) { *this *= fromAxisAngle({1.0f, 0.0f, 0.0f}, angle); }

View File

@ -26,7 +26,7 @@ struct CRelAngle
return ret; return ret;
} }
operator float() { return angle; } operator float() const { return angle; }
static CRelAngle FromRadians(float angle) { return CRelAngle(angle); } static CRelAngle FromRadians(float angle) { return CRelAngle(angle); }
bool operator <(const CRelAngle& other) const { return angle < other.angle; } bool operator <(const CRelAngle& other) const { return angle < other.angle; }
@ -34,6 +34,8 @@ struct CRelAngle
CRelAngle& operator +=(float r) { angle += r; return *this; } CRelAngle& operator +=(float r) { angle += r; return *this; }
CRelAngle& operator *=(const CRelAngle& other) { angle *= other.angle; return *this; } CRelAngle& operator *=(const CRelAngle& other) { angle *= other.angle; return *this; }
CRelAngle& operator *=(float r) { angle *= r; return *this;} CRelAngle& operator *=(float r) { angle *= r; return *this;}
CRelAngle& operator /=(const CRelAngle& other) { angle /= other.angle; return *this;}
CRelAngle& operator /=(float r) { angle /= r; return *this;}
}; };
} }