Blender  V2.59
AUD_3DMath.h
Go to the documentation of this file.
00001 /*
00002  * $Id: AUD_3DMath.h 35141 2011-02-25 10:21:56Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * Copyright 2009-2011 Jörg Hermann Müller
00007  *
00008  * This file is part of AudaSpace.
00009  *
00010  * Audaspace is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * AudaSpace is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with Audaspace; if not, write to the Free Software Foundation,
00022  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00023  *
00024  * ***** END GPL LICENSE BLOCK *****
00025  */
00026 
00032 #ifndef AUD_3DMATH
00033 #define AUD_3DMATH
00034 
00035 class AUD_Quaternion
00036 {
00037 private:
00038         union
00039         {
00040                 float m_v[4];
00041                 struct
00042                 {
00043                         float m_w;
00044                         float m_x;
00045                         float m_y;
00046                         float m_z;
00047                 };
00048         };
00049 
00050 public:
00058         inline AUD_Quaternion(float w, float x, float y, float z) :
00059                 m_w(w), m_x(x), m_y(y), m_z(z)
00060         {
00061         }
00062 
00067         inline const float& w() const
00068         {
00069                 return m_w;
00070         }
00071 
00076         inline const float& x() const
00077         {
00078                 return m_x;
00079         }
00080 
00085         inline const float& y() const
00086         {
00087                 return m_y;
00088         }
00089 
00094         inline const float& z() const
00095         {
00096                 return m_z;
00097         }
00098 
00103         inline void get(float* destination) const
00104         {
00105                 destination[0] = m_w;
00106                 destination[1] = m_x;
00107                 destination[2] = m_y;
00108                 destination[3] = m_z;
00109         }
00110 
00115         inline const float* get() const
00116         {
00117                 return m_v;
00118         }
00119 };
00120 
00121 class AUD_Vector3
00122 {
00123 private:
00124         union
00125         {
00126                 float m_v[3];
00127                 struct
00128                 {
00129                         float m_x;
00130                         float m_y;
00131                         float m_z;
00132                 };
00133         };
00134 
00135 public:
00142         inline AUD_Vector3(float x, float y, float z) :
00143                 m_x(x), m_y(y), m_z(z)
00144         {
00145         }
00146 
00151         inline const float& x() const
00152         {
00153                 return m_x;
00154         }
00155 
00160         inline const float& y() const
00161         {
00162                 return m_y;
00163         }
00164 
00169         inline const float& z() const
00170         {
00171                 return m_z;
00172         }
00173 
00178         inline void get(float* destination) const
00179         {
00180                 destination[0] = m_x;
00181                 destination[1] = m_y;
00182                 destination[2] = m_z;
00183         }
00184 
00189         inline const float* get() const
00190         {
00191                 return m_v;
00192         }
00193 };
00194 
00195 #endif //AUD_3DMATH