Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

angles.cpp

Go to the documentation of this file.
00001 /* *************************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
00017 ************************************************************************************* */
00018 
00019 #include "angles.h"
00020 
00021 void Angles::Zero()
00022 {
00023         isUpdatedEuler=TRUE;
00024         isUpdatedQuaternion=TRUE;
00025         euler.Zero();
00026 }
00027 
00028 Angles::Angles()
00029 {
00030         Zero();
00031 }
00032 
00033 void Angles::operator= (Angles &src)
00034 {
00035         quaternion=src.quaternion;
00036         euler=src.euler;
00037         isUpdatedEuler=src.isUpdatedEuler;
00038         isUpdatedQuaternion=src.isUpdatedQuaternion;
00039 }
00040 
00041 Point3D<double> Angles::GetEuler()
00042 {
00043         if (!isUpdatedEuler) 
00044         {
00045                 euler = quaternion.to_euler();
00046                 isUpdatedEuler=TRUE;
00047         }
00048         return euler;
00049 }
00050 
00051 Angles::Angles(Point3D<double> &relativeAngles)
00052 {
00053         Zero();
00054         Set(relativeAngles);
00055 }
00056 
00057 Angles::Angles(double x,double y,double z) 
00058 {
00059         Zero();
00060         Set(x,y,z);
00061 }
00062 
00063 void Angles::Rotate(Point3D<double> &relativeAngles)
00064 {
00065         if (!isUpdatedQuaternion) 
00066         {
00067                 quaternion.from_euler(euler);
00068                 isUpdatedQuaternion=TRUE;
00069         }
00070         Quaternion qrotate;
00071         qrotate.from_euler(relativeAngles);
00072         quaternion*=qrotate;
00073 }
00074 
00075 void Angles::Rotate(double x,double y,double z)
00076 {
00077         if (!isUpdatedQuaternion) 
00078         {
00079                 quaternion.from_euler(euler);
00080                 isUpdatedQuaternion=TRUE;
00081         }
00082         Quaternion qrotate;
00083         Point3D<double> rotate(x,y,z);
00084         qrotate.from_euler(rotate);
00085         quaternion*=qrotate;
00086         isUpdatedEuler=FALSE;
00087 }
00088 
00089 void Angles::Set(Point3D<double> &relativeAngles)
00090 {
00091         euler=relativeAngles;
00092         isUpdatedQuaternion=FALSE;
00093 }
00094 
00095 void Angles::Set(double x,double y,double z)
00096 {
00097         euler.Set(x,y,z);
00098         isUpdatedQuaternion=FALSE;
00099 }
00100 
00101 void Angles::Add(Point3D<double> &relativeAngles)
00102 {
00103         if (relativeAngles.IsNotNull()) 
00104         {
00105                 euler+=relativeAngles;
00106                 isUpdatedQuaternion=FALSE;
00107         }
00108 }
00109 
00110 void Angles::Add(double x,double y,double z)
00111 {
00112         if (x||y||z) 
00113         {
00114                 euler.Add(x,y,z);
00115                 isUpdatedQuaternion=FALSE;
00116         }
00117 }

Generated on Fri Aug 20 19:19:42 2004 for 3d Controls by doxygen 1.3.6