Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

vector.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           vector.h  -  description
00003                              -------------------
00004     begin                : Sun Jul 22 2001
00005     copyright            : (C) 2001 by T Kontkanen
00006     email                : tkontkanen@mail.com
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 VECTOR_H
00019 #define VECTOR_H
00020 
00021 #include <math.h>
00022 #include <msgout.h>
00023 
00029 // Note: Vector class currently not tested, may be buggy
00030 class Vector {
00031 public:
00033     Vector( float i1=0, float j1=0, float k1=0 ) { vi=i1; vj=j1; vk=k1; }
00034     ~Vector();
00036     void set( float i1=-1, float j1=-1, float k1=-1 ) { if(i1!=-1)vi=i1; if(j1!=-1)vj=j1; if(k1!=-1)vk=k1; }
00038     void setI( float val ) { vi=val; }
00040     void setJ( float val ) { vj=val; }
00042     void setK( float val ) { vk=val; }
00044     void setX( float val ) { vi=val; }
00046     void setY( float val ) { vj=val; }
00048     void setZ( float val ) { vk=val; }
00050     float i() { return vi; }
00052     float j() { return vj; }
00054     float k() { return vk; }
00056     float x() { return vi; }
00058     float y() { return vj; }
00060     float z() { return vk; }
00062     float* ijk();
00064     float* xyz() { return ijk(); }
00066     void rotateX( float vx );
00068     void rotateY( float vx );
00070     void rotateZ( float vx );
00072     void normalize();
00074     void scale( float x );
00076     bool isValid() const { if( length()>0.0000001 ) return true; else return false; }
00078     float length() const { return sqrt( vi*vi + vj*vj + vk*vk ); }  
00080     float dot( const Vector &vector ) const; //dot product
00082     float dot( const Vector &vector, const Vector &vector2 ) const;
00084     float angle( const Vector &v ) const {
00085         if( isValid() && v.isValid() )
00086             return acos( dot(v)/(v.length()*length()) );
00087         else return 0;
00088     }
00089     
00090     Vector operator*(const float mul);
00091     Vector operator/(const float div);
00092     Vector operator=(const Vector& vector);
00093     Vector operator+(const Vector& vector);
00094     Vector operator-(const Vector& vector);
00095     Vector operator+=(const Vector& vector);
00096     Vector operator-=(const Vector& vector);
00098     bool operator>=(const Vector& vector);
00099     bool operator>(const Vector& vector);
00100     bool operator<=(const Vector& vector);
00101     bool operator<(const Vector& vector);
00102     
00103 private:
00104     float vi, vj, vk;
00105 };
00106 
00107 #endif

Generated at Fri Oct 5 20:23:53 2001 for Executor by doxygen1.2.10 written by Dimitri van Heesch, © 1997-2001