/* math/axis.h This file is part of the Osirion project and is distributed under the terms of the GNU General Public License version 2 */ #ifndef __INCLUDED_MATH_AXIS_H__ #define __INCLUDED_MATH_AXIS_H__ #include #include "math/vector3f.h" namespace math { /// a local coordinates system class Axis { public: Axis(); Axis(const Axis & other); void clear(); void assign(const Axis & other); /// global coordinates of the X-axis in the local coordinates system inline const Vector3f & forward() const { return axis_vector[0]; } /// global coordinates of the Y-axis in the local coordinates system inline const Vector3f & left() const { return axis_vector[1]; } /// global coordinates of the Z-axis in the local coordinates system inline const Vector3f & up() const { return axis_vector[2]; } inline Vector3f & operator[](size_t index) { return axis_vector[index]; } inline const Vector3f & operator[](size_t index) const { return axis_vector[index]; } Axis & operator=(const Axis & other); const Axis operator*(const Axis &other) const; /// change direction, rotate around up vector (positive is left) void change_direction(const float angle); /// change pitch, rotate around left vector (positive is up) void change_pitch(const float angle); /// change roll, rotate around forward vector (positive is left) void change_roll(const float angle); /// rotation about an arbitrary axis void rotate(const Vector3f & normal, const float angle); /// return the transpose of this matrix const Axis transpose() const; private: Vector3f axis_vector[3]; }; /// write an axis to a std::ostream std::ostream &operator<<(std::ostream & os, const Axis & axis); /// read an axis from a std::istream std::istream &operator>>(std::istream & is, Axis & axis); /// local-to-global coordinates Vector3f operator*(const Axis &axis, const Vector3f &vector); } #endif // __INCLUDED_MATH_AXIS_H__