Quaternion.h

Go to the documentation of this file.
00001 /*************************************************************************
00002 *                                                                       *
00003 * Open Physics Abstraction Layer                                        *
00004 * Copyright (C) 2004-2005                                               *
00005 * Alan Fischer  alan.fischer@gmail.com                                  *
00006 * Andres Reinot  andres@reinot.com                                      *
00007 * Tyler Streeter  tylerstreeter@gmail.com                               *
00008 * All rights reserved.                                                  *
00009 * Web: opal.sourceforge.net                                             *
00010 *                                                                       *
00011 * This library is free software; you can redistribute it and/or         *
00012 * modify it under the terms of EITHER:                                  *
00013 *   (1) The GNU Lesser General Public License as published by the Free  *
00014 *       Software Foundation; either version 2.1 of the License, or (at  *
00015 *       your option) any later version. The text of the GNU Lesser      *
00016 *       General Public License is included with this library in the     *
00017 *       file license-LGPL.txt.                                          *
00018 *   (2) The BSD-style license that is included with this library in     *
00019 *       the file license-BSD.txt.                                       *
00020 *                                                                       *
00021 * This library is distributed in the hope that it will be useful,       *
00022 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00023 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files    *
00024 * license-LGPL.txt and license-BSD.txt for more details.                *
00025 *                                                                       *
00026 *************************************************************************/
00027 
00028 #ifndef OPAL_QUATERNION_H
00029 #define OPAL_QUATERNION_H
00030 
00031 // project headers
00032 #include "OpalMath.h"
00033 #include "Portability.h"
00034 
00035 // system headers
00036 #include <iostream>
00037 
00038 namespace opal
00039 {
00040         class Vec3r;
00041         
00042     class Quaternion
00043     {
00044         public:
00045             real w;
00046             real x;
00047             real y;
00048             real z;
00049 
00050             OPAL_DECL Quaternion();
00051 
00052             OPAL_DECL Quaternion( real ww, real xx, real yy, real zz );
00053 
00054             OPAL_DECL Quaternion( const Quaternion& src );
00055 
00056             OPAL_DECL void OPAL_CALL set( real ww, real xx, real yy, real zz );
00057 
00058             OPAL_DECL real OPAL_CALL lengthSquared() const;
00059 
00060             OPAL_DECL real OPAL_CALL length() const;
00061 
00063             OPAL_DECL void OPAL_CALL normalize();
00064 
00066 
00072             OPAL_DECL void OPAL_CALL getAngleAxis( real & angle, Vec3r & axis ) const;
00073 
00074             OPAL_DECL real OPAL_CALL getRoll() const;
00075 
00076             OPAL_DECL real OPAL_CALL getPitch() const;
00077 
00078             OPAL_DECL real OPAL_CALL getYaw() const;
00079 
00080             OPAL_DECL real & OPAL_CALL operator[] ( unsigned int i );
00081 
00082             OPAL_DECL const real & OPAL_CALL operator[] ( unsigned int i ) const;
00083     };
00084 
00085         OPAL_DECL Quaternion operator+( const Quaternion &q1, const Quaternion &q2 );
00086         OPAL_DECL Quaternion operator-( const Quaternion &q1, const Quaternion &q2 );
00087         OPAL_DECL Quaternion operator*( const Quaternion& q, real scalar );
00088         OPAL_DECL Quaternion operator*( real scalar, const Quaternion& q );
00089         OPAL_DECL bool operator==( const Quaternion &q1, const Quaternion &q2 );
00090         OPAL_DECL bool operator!=( const Quaternion &q1, const Quaternion &q2 );
00091 
00093         OPAL_DECL std::ostream & operator<<( std::ostream& o, const Quaternion& q );
00094 
00095 }
00096 
00097 #endif

Generated on Tue May 16 17:49:52 2006 for OPAL by  doxygen 1.4.6-NO