Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

vec4.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Stephen Bridges                                 *
00003  *   widget@widget.dynu.com                                                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 #ifndef VEC4_H
00021 #define VEC4_H
00022 
00023 // #include "matrix4x4.h"
00024 
00027 class Matrix4x4;
00028 
00029 // $Id$
00030 
00037 class Vec4
00038 {
00039 public:
00040     Vec4();
00041     Vec4(float *in);
00042     Vec4(float x, float y, float z, float w);
00043     ~Vec4();
00044     // Copy time
00045     Vec4(const Vec4 &other);
00046     Vec4 &operator=(const Vec4 &other);
00047     
00048     inline float &operator()(unsigned int i);
00049     inline float operator ()(unsigned int i) const;
00050     // Add operator
00051     Vec4 operator+(const Vec4& other) const;
00052     Vec4 &operator+=(const Vec4& other);
00053     // Subtract
00054     Vec4 operator-(const Vec4& other) const;
00055     Vec4 &operator-=(const Vec4& other);
00056     Vec4 operator-(void) const;
00057     // Divide
00058     Vec4 operator/(const float &other) const;
00059     Vec4 &operator/=(const float &other);
00060     // Multiply
00061     Vec4 operator*(const float &other) const;
00062     Vec4 &operator*=(const float &other);
00063     // Multiply by matrix
00064     Vec4 operator*(const Matrix4x4 &other) const;
00065     Vec4 &operator*=(const Matrix4x4 &other);
00066     // Comparators
00067     bool operator==(const Vec4 &other) const;
00068     bool operator!=(const Vec4 &other) const;
00070     float v[4];
00071     void Zero(void);
00072     void Print(void);
00073     float Length(void);
00074     inline float SqrLength(void);
00075     void Normalise(void);
00076     void Clean(void);
00077     int mainDir(void);
00078     void rotate(float xin, float yin, float zin);
00079 };
00080 
00081 Vec4 cross(Vec4 v1, Vec4 v2);
00082 float dot(Vec4 v1, Vec4 v2);
00083 // void crossv(float *out, float *in1, float *in2);
00084 // void trinorm(float *out, float *in1, float *in2, float *in3);
00085 
00091 inline float &Vec4::operator()(unsigned int i)
00092 {
00093     return v[i];
00094 }
00095 
00101 inline float Vec4::operator ()(unsigned int i) const
00102 {
00103     return v[i];
00104 }
00105 
00111 inline float Vec4::SqrLength(void)
00112 {
00113     return v[0]*v[0] + v[1]*v[1] + v[2]*v[2];
00114 }
00115 
00116 #endif
00117 
00118 /*
00119  * $Log$
00120  */
00121 
00122 // EOF
00123    

Generated on Mon Jan 3 15:14:19 2005 for Graviton by  doxygen 1.3.9.1