Blender V2.61 - r43446

MT_ExpMap.h

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Original author: Laurence
00024  * Contributor(s): Brecht
00025  *
00026  * ***** END GPL LICENSE BLOCK *****
00027  */
00028 
00034 #ifndef MT_ExpMap_H
00035 #define MT_ExpMap_H
00036 
00037 #include <MT_assert.h>
00038 
00039 #include "MT_Vector3.h"
00040 #include "MT_Quaternion.h"
00041 #include "MT_Matrix4x4.h"
00042 
00043 const MT_Scalar MT_EXPMAP_MINANGLE (1e-7);
00044 
00080 class MT_ExpMap {
00081 public:
00082 
00089     MT_ExpMap() {}
00090     MT_ExpMap(const MT_Vector3& v) : m_v(v) { angleUpdated(); }
00091 
00092     MT_ExpMap(const float v[3]) : m_v(v) { angleUpdated(); }
00093     MT_ExpMap(const double v[3]) : m_v(v) { angleUpdated(); }
00094 
00095     MT_ExpMap(MT_Scalar x, MT_Scalar y, MT_Scalar z) :
00096         m_v(x, y, z) { angleUpdated(); }
00097 
00102     MT_ExpMap(
00103         const MT_Quaternion &q
00104     ) {
00105         setRotation(q);
00106     };
00107 
00116     const 
00117         MT_Vector3 &
00118     vector(
00119     ) const {
00120         return m_v;
00121     };
00122 
00127         void
00128     setRotation(
00129         const MT_Quaternion &q
00130     );
00131 
00137         const MT_Quaternion&
00138     getRotation(
00139     ) const;
00140 
00145         MT_Matrix3x3
00146     getMatrix(
00147     ) const; 
00148     
00154         void
00155     update(
00156         const MT_Vector3& dv
00157     );
00158 
00165         void
00166     partialDerivatives(
00167         MT_Matrix3x3& dRdx,
00168         MT_Matrix3x3& dRdy,
00169         MT_Matrix3x3& dRdz
00170     ) const ;
00171     
00172 private :
00173 
00174     // m_v contains the exponential map, the other variables are
00175     // cached for efficiency
00176     
00177     MT_Vector3 m_v;
00178     MT_Scalar m_theta, m_sinp;
00179     MT_Quaternion m_q;
00180 
00181     // private methods
00182 
00183     // Compute partial derivatives dR (3x3 rotation matrix) / dVi (EM vector)
00184     // given the partial derivative dQ (Quaternion) / dVi (ith element of EM vector)
00185 
00186         void
00187     compute_dRdVi(
00188         const MT_Quaternion &dQdV,
00189         MT_Matrix3x3 & dRdVi
00190     ) const;
00191 
00192     // compute partial derivatives dQ/dVi
00193 
00194         void
00195     compute_dQdVi(
00196         MT_Quaternion *dQdX
00197     ) const ; 
00198 
00199     // reparametrize away from singularity
00200 
00201         void
00202     reParametrize(
00203     );
00204 
00205     // (re-)compute cached variables
00206 
00207         void
00208     angleUpdated(
00209     );
00210 };
00211 
00212 #endif
00213