From a2834d74d2e6f243cfbe94658e6add862798d961 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 5 Sep 2003 20:52:36 +0000 Subject: [PATCH] Added set and get methods for Matrixd and Matrixf. --- include/osg/Quat | 12 ++++++++++++ src/osg/Quat.cpp | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/include/osg/Quat b/include/osg/Quat index 7fcaabe01..9269fc9e3 100644 --- a/include/osg/Quat +++ b/include/osg/Quat @@ -20,6 +20,9 @@ namespace osg { +class Matrixf; +class Matrixd; + /** A quaternion class. It can be used to represent an orientation in 3D space.*/ class SG_EXPORT Quat { @@ -87,6 +90,15 @@ class SG_EXPORT Quat { _fv = v; } + + void set(const Matrixf& matrix); + + void set(const Matrixd& matrix); + + void get(Matrixf& matrix) const; + + void get(Matrixd& matrix) const; + inline float& operator [] (int i) { return _fv[i]; } inline float operator [] (int i) const { return _fv[i]; } diff --git a/src/osg/Quat.cpp b/src/osg/Quat.cpp index b88da80a7..fc9ec48ff 100644 --- a/src/osg/Quat.cpp +++ b/src/osg/Quat.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include #include @@ -24,6 +26,27 @@ using namespace osg; +void Quat::set(const Matrixf& matrix) +{ + matrix.get(*this); +} + +void Quat::set(const Matrixd& matrix) +{ + matrix.get(*this); +} + +void Quat::get(Matrixf& matrix) const +{ + matrix.set(*this); +} + +void Quat::get(Matrixd& matrix) const +{ + matrix.set(*this); +} + + /// Set the elements of the Quat to represent a rotation of angle /// (radians) around the axis (x,y,z) void Quat::makeRotate( float angle,