src/tetmesh/vector4.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           vector4.h  -  description
00003                              -------------------
00004     begin                : Fri Dec 12 2003
00005     copyright            : (C) 2003 by Roman Geus
00006     email                : roman.geus@psi.ch
00007 ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef __Vector4_H__
00019 #define __Vector4_H__
00020 
00021 namespace mesh
00022 {
00023 #define Real double
00024 
00027 class Vector4
00028 {
00029 public:
00030     Real x, y, z, w;
00031 
00032 public:
00033     inline Vector4()
00034     {}
00035 
00036     inline Vector4( Real fX, Real fY, Real fZ, Real fW )
00037         : x( fX ), y( fY ), z( fZ ), w( fW)
00038     {}
00039 
00040     inline Vector4( Real afCoordinate[4] )
00041         : x( afCoordinate[0] ),
00042           y( afCoordinate[1] ),
00043           z( afCoordinate[2] ),
00044           w( afCoordinate[3] )
00045     {}
00046 
00047     inline Vector4( int afCoordinate[4] )
00048     {
00049         x = (Real)afCoordinate[0];
00050         y = (Real)afCoordinate[1];
00051         z = (Real)afCoordinate[2];
00052         w = (Real)afCoordinate[3];
00053     }
00054 
00055     inline Vector4( const Real* const r )
00056         : x( r[0] ), y( r[1] ), z( r[2] ), w( r[3] )
00057     {}
00058 
00059     inline Vector4( const Vector4& rkVector )
00060         : x( rkVector.x ), y( rkVector.y ), z( rkVector.z ), w (rkVector.w)
00061     {}
00062 
00063     inline Real operator [] ( unsigned i ) const
00064     {
00065         assert( i < 4 );
00066 
00067         return *(&x+i);
00068     }
00069 
00070     inline Real& operator [] ( unsigned i )
00071     {
00072         assert( i < 4 );
00073 
00074         return *(&x+i);
00075     }
00076 
00081     inline Vector4& operator = ( const Vector4& rkVector )
00082     {
00083         x = rkVector.x;
00084         y = rkVector.y;
00085         z = rkVector.z;
00086         w = rkVector.w;
00087 
00088         return *this;
00089     }
00090 
00091     inline bool operator == ( const Vector4& rkVector ) const
00092     {
00093         return ( x == rkVector.x &&
00094                  y == rkVector.y &&
00095                  z == rkVector.z &&
00096                  w == rkVector.w );
00097     }
00098 
00099     inline bool operator != ( const Vector4& rkVector ) const
00100     {
00101         return ( x != rkVector.x ||
00102                  y != rkVector.y ||
00103                  z != rkVector.z ||
00104                  w != rkVector.w );
00105     }
00106 
00107     inline Vector4& operator = (const Vector3& rhs)
00108     {
00109         x = rhs.x;
00110         y = rhs.y;
00111         z = rhs.z;
00112         w = 1.0f;
00113         return *this;
00114     }
00115 
00116 #if 0
00117     inline Vector4 operator * (const Matrix4& mat) const
00118     {
00119         return Vector4(
00120                        x*mat[0][0] + y*mat[1][0] + z*mat[2][0] + w*mat[3][0],
00121                        x*mat[0][1] + y*mat[1][1] + z*mat[2][1] + w*mat[3][1],
00122                        x*mat[0][2] + y*mat[1][2] + z*mat[2][2] + w*mat[3][2],
00123                        x*mat[0][3] + y*mat[1][3] + z*mat[2][3] + w*mat[3][3]
00124                        );
00125     }
00126 #endif
00127 
00128 
00136     inline Real dotProduct(const Vector4& vec) const
00137     {
00138         return x * vec.x + y * vec.y + z * vec.z + w * vec.w;
00139     }
00142     inline friend std::ostream& operator << ( std::ostream& o, const Vector4& v )
00143     {
00144         o << "Vector4(" << v.x << ", " << v.y << ", " << v.z << ", " << v.w << ")";
00145         return o;
00146     }
00147 };
00148 
00149 #undef Real
00150 } // namespace mesh
00151 
00152 #endif

Generated on Fri Oct 26 13:35:13 2007 for FEMAXX (Finite Element Maxwell Eigensolver) by  doxygen 1.4.7