diff options
author | Stijn Buys <ingar@osirion.org> | 2010-10-04 16:59:52 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2010-10-04 16:59:52 +0000 |
commit | 3d97c7737fdda88c5d5d9e3e7d13f4c1973c7774 (patch) | |
tree | f4ee6f9e88645f76786589f1cb929eade66ce858 /src | |
parent | 81acfb7cd3ced1e613acaf45b44867e56b137dc9 (diff) |
corrected modelview rotation to radians
Diffstat (limited to 'src')
-rw-r--r-- | src/math/axis.cc | 6 | ||||
-rw-r--r-- | src/math/axis.h | 25 | ||||
-rwxr-xr-x | src/ui/modelview.cc | 4 |
3 files changed, 25 insertions, 10 deletions
diff --git a/src/math/axis.cc b/src/math/axis.cc index 402b2f6..8273469 100644 --- a/src/math/axis.cc +++ b/src/math/axis.cc @@ -84,10 +84,10 @@ void Axis::change_roll(const float angle) /* notes: http://mathworld.wolfram.com/RotationFormula.html */ -void Axis::rotate(Vector3f const &normal, float angle) +void Axis::rotate(Vector3f const &normal, float rad) { - float cosa = cosf(angle); - float sina = sinf(angle); + float cosa = cosf(rad); + float sina = sinf(rad); for (size_t i = 0; i < 3; i++) { axis_vector[i] = diff --git a/src/math/axis.h b/src/math/axis.h index 0ece016..c22568c 100644 --- a/src/math/axis.h +++ b/src/math/axis.h @@ -52,17 +52,32 @@ public: const Axis operator*(const Axis &other) const; - /// change direction, rotate around up vector (positive is left) + /** + * @brief change axis direction angle + * rotate around axis up vector (positive is left) + * @param angle angle in degrees + **/ void change_direction(const float angle); - /// change pitch, rotate around left vector (positive is up) + /** + * @brief change axis pitch angle + * rotate around left vector (positive is up) + * @param angle angle in degrees + **/ void change_pitch(const float angle); - /// change roll, rotate around forward vector (positive is left) + /** + * @brief change axis roll angle + * rotate around forward vector (positive is left) + * @param angle angle in degrees + **/ void change_roll(const float angle); - /// rotation about an arbitrary axis - void rotate(const Vector3f & normal, const float angle); + /** + * @brief rotation about an arbitrary vector + * @param rad angle in radians + **/ + void rotate(const Vector3f & normal, const float rad); /// return the transpose of this matrix const Axis transpose() const; diff --git a/src/ui/modelview.cc b/src/ui/modelview.cc index 7eb1be6..b247213 100755 --- a/src/ui/modelview.cc +++ b/src/ui/modelview.cc @@ -108,12 +108,12 @@ void ModelView::on_mousemove(const math::Vector2f &cursor) const math::Vector2f pos(cursor - modelview_cursor); const math::Vector3f up(0.0f, 0.0f, 1.0f); - const float zrot = 45.0f * pos.x() / width(); + const float zrot = 2.0f * M_PI * pos.x() / width(); modelview_axis.rotate(up, -zrot); //modelview_manipaxis.rotate(up, -zrot); const math::Vector3f left(0.0f, 1.0f, 0.0f); - const float yrot = 45.0f * pos.y() / height(); + const float yrot = 2.0f * M_PI * pos.y() / height(); modelview_axis.rotate(left, yrot); //modelview_manipaxis.rotate(left, yrot); |