/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */ /* $Id: vctQuaternionRotation3.h,v 1.38 2007/04/26 19:33:58 anton Exp $ Author(s): Anton Deguet Created on: 2004-01-15 (C) Copyright 2004-2007 Johns Hopkins University (JHU), All Rights Reserved. --- begin cisst license - do not edit --- This software is provided "as is" under an open source license, with no warranty. The complete license can be found in license.txt and http://www.cisst.org/cisst/license.txt. --- end cisst license --- */ /*! \file \brief Declaration of vctQuaternionRotation3 */ #ifndef _vctQuaternionRotation3_h #define _vctQuaternionRotation3_h #include #include #include /*! \brief Define a rotation quaternion for a space of dimension 3 \ingroup cisstVector This class is templated by the element type. It is derived from vctMatrixRotation2Base and uses a vctFixedSizeMatrix as underlying container. It provides a more humain interface for programmers only interested in templating by _elementType. \param _elementType The type of elements of the quaternion. \sa vctQuaternionRotation3Base vctFixedSizeVector */ template class vctQuaternionRotation3: public vctQuaternionRotation3Base > { public: /* no need to document, inherit doxygen documentation from vctFixedSizeVectorBase */ VCT_CONTAINER_TRAITS_TYPEDEFS(_elementType); enum {SIZE = 4}; enum {DIMENSION = 3}; typedef vctFixedSizeVector ContainerType; typedef vctQuaternionRotation3Base BaseType; typedef vctQuaternionRotation3 ThisType; /*! Traits used for all useful types and values related to the element type. */ typedef cmnTypeTraits TypeTraits; /* documented in base class */ inline vctQuaternionRotation3(): BaseType() {} inline vctQuaternionRotation3(const ThisType & quaternionRotation): BaseType(quaternionRotation) {} template inline vctQuaternionRotation3(const _containerType & vector4) throw(std::runtime_error): BaseType(vector4) {} inline vctQuaternionRotation3(const value_type & x, const value_type & y, const value_type & z, const value_type & r) throw(std::runtime_error): BaseType(x, y, z, r) {} template inline explicit vctQuaternionRotation3(const vctMatrixRotation3Base<__containerType> & matrixRotation) throw(std::runtime_error): BaseType(matrixRotation) {} inline vctQuaternionRotation3(const vctAxisAngleRotation3 & axisAngleRotation) throw(std::runtime_error): BaseType(axisAngleRotation) {} template inline vctQuaternionRotation3(const vctRodriguezRotation3Base<__containerType> & rodriguezRotation) throw(std::runtime_error): BaseType(rodriguezRotation) {} inline vctQuaternionRotation3(const ThisType & quaternionRotation, bool normalizeInput): BaseType(quaternionRotation, normalizeInput) {} template inline vctQuaternionRotation3(const _containerType & vector4, bool normalizeInput): BaseType(vector4, normalizeInput) {} inline vctQuaternionRotation3(const value_type & x, const value_type & y, const value_type & z, const value_type & r, bool normalizeInput): BaseType(x, y, z, r, normalizeInput) {} template inline explicit vctQuaternionRotation3(const vctMatrixRotation3Base<__containerType> & matrixRotation, bool normalizeInput): BaseType(matrixRotation, normalizeInput) {} inline vctQuaternionRotation3(const vctAxisAngleRotation3 & axisAngleRotation, bool normalizeInput): BaseType(axisAngleRotation, normalizeInput) {} template inline vctQuaternionRotation3(const vctRodriguezRotation3Base<__containerType> & rodriguezRotation, bool normalizeInput): BaseType(rodriguezRotation, normalizeInput) {} /*! The assignment from BaseType has to be redefined for this class (C++ restriction). This operator uses the Assign() method inherited from the ContainerType. This operator (as well as the Assign method) allows to set a rotation quaternion to whatever value without any further validity checking. It is recommended to use it with caution. */ inline ThisType & operator = (const BaseType & other) { return reinterpret_cast(this->Assign(other)); } }; #endif // _vctQuaternionRotation3_h // **************************************************************************** // Change History // **************************************************************************** // // $Log: vctQuaternionRotation3.h,v $ // Revision 1.38 2007/04/26 19:33:58 anton // All files in libraries: Applied new license text, separate copyright and // updated dates, added standard header where missing. // // Revision 1.37 2007/02/05 20:04:42 anton // cisstVector: Re-added and cleaned up rotations classes as requested in #266 // // Revision 1.36 2007/01/29 03:29:37 anton // cisstVector: Update quaternion and quaternion based rotation to reflect new // class structure (see ticket #263). // // Revision 1.35 2006/11/20 20:33:20 anton // Licensing: Applied new license to cisstCommon, cisstVector, cisstNumerical, // cisstInteractive, cisstImage and cisstOSAbstraction. // // Revision 1.34 2006/01/03 03:38:58 anton // cisstVector Doxygen: Used \code \endcode instead of
 
, added // some missing
, added links to VCT_NORMALIZE. // // Revision 1.33 2005/10/06 16:56:37 anton // Doxygen: Corrected errors and some warnings detected by Doxygen 1.4.3. // // Revision 1.32 2005/09/28 20:31:06 anton // vctQuaternionRotation: Major update to implement ticket #110 re. initial // conditions for conversion methods (i.e. normalization of input). // // Revision 1.31 2005/09/26 15:41:47 anton // cisst: Added modelines for emacs and vi. // // Revision 1.30 2005/09/01 06:18:08 anton // cisstVector transformations: Added a level of abstraction for all classes // derived from fixed size containers (vctQuaternion, vctQuaternionRotation3, // vctMatrixRotation3, vctRodriguezRotation3). These classes are now derived // from vctXyzBase<_containerType>. This will ease the SWIG wrapping. // // Revision 1.29 2005/07/22 19:06:46 ofri // vct[Quaternion|Matrix]Rotation[2|3]: Fixing compilation error related to // check-in [1253]. // // Revision 1.28 2005/07/22 15:08:21 ofri // Answer for ticket #155: added operator * that returns ThisType to // vctMatrixRotation2, vctMatrixRotation3, vctQuaternionRotation3 // // Revision 1.27 2005/06/16 03:38:29 anton // Port to gcc 3.4 (common, vector and numerical) tested with gcc 3.3 and MS // VC 7.1 (.Net 2003). // // Revision 1.26 2005/05/19 19:29:01 anton // cisst libs: Added the license to cisstCommon and cisstVector // // Revision 1.25 2005/04/28 03:58:35 anton // cisstVector: Added methods ApplyTo(input) returning by copy as specified // in ticket #108. Added Doxygen documentation and moved from EqualRotation() // to AlmostEqual(). // // Revision 1.24 2005/02/08 22:10:35 ofri // vctQuaternionRotation3: converted norm and angle types to double (following // ticket #128) // // Revision 1.23 2005/02/07 02:54:52 anton // vctQuaternionRotation3: Major update to reflect ticket #109. // // Revision 1.22 2005/02/04 16:56:54 anton // cisstVector: Added classes vctAxisAngleRotation3 and vctRodriguezRotation3 // as planed in ticket #109. Also updated vctMatrixRotation3 to use these new // classes. Other updates include vctRandom(rotation), new vctTypes and // forward declarations. // // Revision 1.21 2004/11/18 20:57:30 ofri // RE: ticket #92. Redefined all operator= I could find to return a ThisType & // instead of const ThisType &. This included corresponding revision of the // Assign methods, and also definition from scratch of operator= for fixed and // dynamic matrix ref. // // Revision 1.20 2004/11/08 18:09:07 anton // cisstVector: Methods Assign(ThisType) require a cast. // // Revision 1.19 2004/11/04 23:11:02 ofri // vctQuaternionRotation3 and vctMatrixRotation3: Added method EqualRotation // and From(ThisType) with their documentation. // // Revision 1.18 2004/10/25 19:19:54 anton // cisstVector: Created vctForwardDeclarations.h and removed forward // declarations of classes in all other files. Added some constructors // for vector references to reference fixed size from dynamic and vice versa. // // Revision 1.17 2004/10/25 13:52:05 anton // Doxygen documentation: Cleanup all the useless \ingroup. // // Revision 1.16 2004/10/06 22:53:03 ofri // classes vctMatrixRotation3, vctQuaternionRotation, vctFrame: Added methods // ApplyTo(vctDynamicConstVectorBase, vctDynamicVectorBase) and // ApplyInverseTo(vctDynamicConstVectorBase, vctDynamicVectorBase) . The library // and the test were compiled successfully on .net7, gcc. No correctess tests // were performed. // // Revision 1.15 2004/08/13 19:27:55 anton // cisstVector: For all the code related to rotations, added some assert to // check that the input is valid (normalized quaternion, normalized axis, // normalized matrix) for all the From method. Added a // vctQuaternionRotation.FromRaw(matrix) since this method is used to normalize // the rotation matrices. It's input doesn't have to be normalized. As a side // effect these additions, found a couple of IsNormalized methods which were // not const. // // Revision 1.14 2004/08/13 17:47:40 anton // cisstVector: Massive renaming to replace the word "sequence" by "vector" // (see ticket #50) as well as another more systematic naming for the engines. // The changes for the API are as follow: // *: vctFixedLengthSequenceBase -> vctFixedSizeVectorBase (and Const) // *: vctFixedLengthSequenceRef -> vctFixedSizeVectorRef (and Const) // *: vctDynamicSequenceBase -> vctDynamicVectorBase (and Const) // *: vctDynamicSequenceRef -> vctDynamicVectorRef (and Const) // *: vctDynamicSequenceRefOwner -> vctDynamicVectorRefOwner // *: vctFixedStrideSequenceIterator -> vctFixedStrideVectorIterator (and Const) // *: vctVarStrideSequenceIterator -> vctVarStrideVectorIterator (and Const) // *: vctSequenceRecursiveEngines -> vctFixedSizeVectorRecursiveEngines // *: vctSequenceLoopEngines -> vctDynamicVectorLoopEngines // *: vctMatrixLoopEngines -> vctFixedSizeMatrixLoopEngines // *: vctDynamicMatrixEngines -> vctDynamicMatrixLoopEngines // Also updated and corrected the documentation (latex, doxygen, figures) as // well as the tests and examples. // // Revision 1.13 2004/07/02 16:16:45 anton // Massive renaming in cisstVector for the addition of dynamic size vectors // and matrices. The dynamic vectors are far from ready. // // Revision 1.12 2004/06/03 21:18:39 ofri // And a couple more typos. // // Revision 1.11 2004/06/03 20:47:13 ofri // ... And, as usual, needed a couple adjustments after testing on Linux. // cisstVectorTests were successful. // // Revision 1.10 2004/06/03 20:38:14 ofri // Changes in vctQuaternionRotation3 and vctMatrixRotation3: // 1) Added constructor and conversion from ``Jacobian vector'' // 2) Some cosmetic changes: documentation, easier debugging. // // Revision 1.9 2004/04/02 15:29:04 anton // Removed CISST_EXPORT for the class, only exports the methods Identity // and From(vctMatrixRotation3). // // Revision 1.8 2004/03/19 15:31:34 ofri // Eliminated direct access of the Data container. Use at() instead. // // Revision 1.7 2004/03/16 21:18:44 ofri // Applying changes deriving from updating the interface of cmnTypeTraits // // Revision 1.6 2004/02/27 02:41:31 ofri // The Identity rotation and frame objects are now declared through a static // method instead of a static object instance. This fixes a bug related to the // order of static object instantiations. // // Revision 1.5 2004/02/18 22:30:42 anton // Added DIMENSION for all transformation to simplify the vctFrame template // // Revision 1.4 2004/02/16 19:42:24 anton // Code for ApplyInverseTo // // Revision 1.3 2004/02/11 18:40:04 anton // From(vecIm, scalReal) replaced by ConcatenationOf from vctFixedLengthSequenceBase // // Revision 1.2 2004/02/11 15:28:15 anton // Added ApplyTo(ThisType), ApplyInverseTo(ThisType) and ApplyInverseTo(sequence) // // Revision 1.1 2004/02/06 15:40:20 anton // Renamed vctRotationQuaternion3 to vctQuaternionRotation3 // Renamed vctRotationMatrix3 to vctMatrixRotation3 // Added Inverse and Normalized methods with consistant naming and signatures // Added constructors from/to quaternion, matrix, axis/angle // // // Revision 1.1 2004/01/16 22:55:06 anton // Creation // // // ****************************************************************************