Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages   Examples  

math/vector3.h

Go to the documentation of this file.
00001 #ifndef MATH_VECTOR3_H
00002 #define MATH_VECTOR3_H
00003 
00004 /*
00005 
00006   GLT OpenGL C++ Toolkit (LGPL)
00007   Copyright (C) 2000-2002 Nigel Stewart  
00008 
00009   Email: nigels.com@gmail.com   
00010   WWW:   http://www.nigels.com/glt/
00011 
00012   This library is free software; you can redistribute it and/or
00013   modify it under the terms of the GNU Lesser General Public
00014   License as published by the Free Software Foundation; either
00015   version 2.1 of the License, or (at your option) any later version.
00016 
00017   This library is distributed in the hope that it will be useful,
00018   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020   Lesser General Public License for more details.
00021 
00022   You should have received a copy of the GNU Lesser General Public
00023   License along with this library; if not, write to the Free Software
00024   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 
00026 */
00027 
00033 #include <iosfwd>
00034 #include <string>
00035 
00036 #include <glt/config.h>
00037 #include <math/real.h>
00038 
00039 class Matrix;
00040 class GltViewport;
00041 
00043 
00050 class Vector
00051 {
00052     friend std::ostream &operator<<(std::ostream &os, const Vector &x);
00053     friend std::istream &operator>>(std::istream &is,       Vector &x);
00054 
00055     friend Vector operator*(const Vector  &v, const real x);
00056     friend Vector operator/(const Vector  &v, const real x);
00057     friend Vector operator*(const real     x, const Vector &v);
00058     friend Vector operator+(const Vector &v1, const Vector &v2);
00059     friend Vector operator-(const Vector &v1, const Vector &v2);
00060     friend Vector xProduct (const Vector &v1, const Vector &v2);
00061 
00062     friend Vector planeNormal(const Vector &v1, const Vector &v2,const Vector &v3);
00063 
00064     friend Vector polar(const real lat,const real longitude);
00065 
00066     friend void orthogonalSystem(Vector &a,Vector &b,Vector &c);
00067 
00068 public:
00070     Vector();
00072     Vector(const Vector &v);
00074     Vector(const real x, const real y,const real z);
00076     Vector(const float  *v);
00078     Vector(const double *v);
00080     Vector(const std::string &str);
00081 
00083           real &x();
00085     const real &x() const;
00086 
00088           real &y();
00090     const real &y() const;
00091 
00093           real &z();
00095     const real &z() const;
00096 
00098           real &operator[](const int i);
00100     const real &operator[](const int i) const;
00101 
00103     operator real *();
00104 
00106     bool operator==(const Vector &v) const;
00108     bool operator!=(const Vector &v) const;
00110     bool operator==(const real &a) const;
00111 
00113     bool operator< (const Vector &c) const;
00115     bool operator> (const Vector &c) const;
00116 
00118     Vector &operator= (const Vector &v);
00120     Vector &operator= (const float *);
00122     Vector &operator= (const double *);
00124     Vector &operator+=(const Vector &v);
00126     Vector &operator-=(const Vector &v);
00127 
00129     real operator*(const Vector &v) const;
00131     Vector &operator*=(const real &x);
00133     Vector &operator*=(const Matrix &m);
00135     Vector operator-() const;
00136 
00138     void scale(const real &x);
00140     void scale(const Vector &x);
00141 
00143     void normalize();
00145     void abs();
00147     int  dominant() const;
00148 
00150     real norm() const;
00152     real dist(const Vector &x) const;
00153 
00155     real length() const;
00156 
00158     bool project(const Matrix &model,const Matrix &proj,const GltViewport &view);
00159 
00161     Vector &vmin(const Vector &v);
00163     Vector &vmax(const Vector &v);
00164 
00166     void glVertex() const;
00168     void glNormal() const;
00170     void glColor() const;
00172     void glTexCoord() const;
00173 
00175     std::ostream &writePov(std::ostream &os) const;
00176 
00177 protected:
00179     real _vector[3];
00180 };
00181 
00183 extern const Vector VectorX;
00185 extern const Vector VectorY;
00187 extern const Vector VectorZ;
00189 extern const Vector Vector0;
00191 extern const Vector Vector1;
00192 
00193 #endif 

Generated on Tue Nov 5 11:11:04 2002 for GLT by doxygen1.2.18