Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Vector.h

00001 // Mesh Algorithms: a library of algorithms to manipulate 3D meshes
00002 // Copyright (C) 2001 Tim Garthwaite and Jason Reposa
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 #ifndef VECTOR_H
00019 #define VECTOR_H
00020 
00021 #include <string>
00022 #include <cstdio>
00023 
00025 class Vector {
00027   float data[4];
00028 
00029  public:
00031   Vector( const float x=0.0, 
00032           const float y=0.0, 
00033           const float z=0.0, 
00034           const float w=1.0 
00035         );
00036 
00037   // Access methods
00038   float   x () const; 
00039   float   y () const; 
00040   float   z () const; 
00041   float   w () const; 
00042 
00043   float & x (); 
00044   float & y (); 
00045   float & z (); 
00046   float & w (); 
00047 
00048   // Methods
00049   float magnitude() const; 
00050   void  normalize(); 
00051   void  set(float nx, float ny, float nz); 
00052 
00053   // Operators
00054   friend Vector operator + (const Vector &v1, const Vector &v2); 
00055   friend Vector operator - (const Vector &v1, const Vector &v2); 
00056   friend float  dot        (const Vector &v1, const Vector &v2); 
00057   friend Vector cross      (const Vector &v1, const Vector &v2); 
00058   std::string toString(); 
00059 
00060 };
00061 
00062 #endif
00063 

Generated on Fri Dec 21 00:16:49 2001 for Mesh Decimation by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001