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

vector.h

Go to the documentation of this file.
00001 /*
00002  *  Part of rvglue source code,
00003  *  Copyright (C) 2000 Alexander Kroeller (alilein@gmx.de)
00004  *  Copyright (C) 2000 Christer Sundin (ces) (christer@sundin.nu)
00005  *  Copyright (C) 2001 Gabor Varga (vag) (bootes@freemail.hu)
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00020  */
00021 
00022 /*
00023  * $Id: vector.h,v 1.2 2000/05/03 09:28:36 ali Exp ali $
00024  *
00025  * $Log: vector.h,v $
00026  * Revision 1.2  2000/05/03 09:28:36  ali
00027  * ces sync
00028  *
00029  * Revision 1.1  2000/05/03 08:49:54  ali
00030  * Initial revision
00031  */
00032 #ifndef __VECTOR_H
00033 #define __VECTOR_H
00034 
00035 #include "rvbasetypes.h"
00036 
00037 
00039 
00045 class Vector
00046 {
00047 public:
00048   Vector();
00049   
00051   Vector(const Vector &);
00052 
00054   Vector(Vector &, Vector &);
00055 
00057   Vector(rvfloat x, rvfloat y, rvfloat z);
00058 
00059   Vector operator - (Vector &);
00060   Vector operator + (Vector &);
00061 
00063   bool operator <= (const Vector &) const;
00064 
00066   Vector operator * (rvfloat scalefac);
00067 
00069   Vector operator / (rvfloat scalediv);  // ces 2000-04-13
00070 
00073   Vector operator * (Vector &);
00074 
00076   bool   operator == (const Vector &) const;
00077   bool   operator != (const Vector &) const;
00078 
00079   rvfloat length(void) const;
00080   rvfloat lengthXZ(void) const;  // ces 2000-04-13
00081 
00088   bool  normalize(void);
00089 
00090   bool  normalizeXZ(void);
00091 
00093   rvfloat scalarprod(const Vector &) const;
00094 
00096   rvfloat scalarprod_xz(const Vector &) const;
00097 
00099   void rotate_right_xz(void);
00100 
00101   bool isnull() const {return length() < EPSILON;}    // vag 2001-05-08
00102 
00104   bool perp(const Vector &v) const {return scalarprod(v) < EPSILON;}
00105 
00107   bool unidir(const Vector &v) const;   // vag 2001-05-08
00108 
00110   static bool right_perp_triplet(Vector &v1, Vector &v2, Vector &v3);   // vag 2001-05-08
00111 
00113   static bool left_perp_triplet(Vector &v1, Vector &v2, Vector &v3);   // vag 2001-05-08
00114 
00115   rvfloat &x(void); 
00116   rvfloat &y(void);
00117   rvfloat &z(void);
00118   rvfloat x(void) const;    // vag 2001-05-08
00119   rvfloat y(void) const;    // vag 2001-05-08
00120   rvfloat z(void) const;    // vag 2001-05-08
00121   rvfloat x(rvfloat);
00122   rvfloat y(rvfloat);
00123   rvfloat z(rvfloat);
00124 
00125   inline rvfloat &operator [] (int i) { return coord[i]; }
00126 
00127   rvfloat coord[3];
00128 };
00129 
00130 #define VECTOR_SIZE sizeof(Vector)
00131 #define VECTOR_STORAGE_SIZE_OKAY (sizeof(Vector) == 3*sizeof(rvfloat))
00132 
00133 #endif

Generated at Mon Jul 2 16:54:58 2001 for rvtmod/rvglue by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000