torcs - 1.2.2

src/modules/simu/simuv2.sav/SOLID-2.0/include/3D/Tuple3.h

Go to the documentation of this file.
00001 /*
00002   3D - C++ Class Library for 3D Transformations
00003   Copyright (C) 1996-1998  Gino van den Bergen
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Library General Public
00007   License as published by the Free Software Foundation; either
00008   version 2 of the License, or (at your option) any later version.
00009 
00010   This library 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 GNU
00013   Library General Public License for more details.
00014 
00015   You should have received a copy of the GNU Library General Public
00016   License along with this library; if not, write to the Free
00017   Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 
00019   Please send remarks, questions and bug reports to gino@win.tue.nl,
00020   or write to:
00021                   Gino van den Bergen
00022                   Department of Mathematics and Computing Science
00023                   Eindhoven University of Technology
00024                   P.O. Box 513, 5600 MB Eindhoven, The Netherlands
00025 */
00026 
00027 #ifndef _TUPLE3_H_
00028 #define _TUPLE3_H_
00029 
00030 #include "Basic.h"
00031 
00032 #include <assert.h>
00033 #include <iostream>
00034 
00035 using namespace std;
00036 
00037 class Tuple3 {
00038 public:
00039   Tuple3() {}
00040   Tuple3(const float v[3]) { setValue(v); }
00041   Tuple3(const double v[3]) { setValue(v); }
00042   Tuple3(Scalar x, Scalar y, Scalar z) { setValue(x, y, z); }
00043   
00044   Scalar&       operator[](int i)       { return comp[i]; }
00045   const Scalar& operator[](int i) const { return comp[i]; }
00046 
00047   Scalar       *getValue()       { return comp; }
00048   const Scalar *getValue() const { return comp; }
00049 
00050   void setValue(const float v[3]) {
00051     comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z];
00052   }
00053   
00054   void setValue(const double v[3]) {
00055     comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z];
00056   }
00057   
00058   void setValue(Scalar x, Scalar y, Scalar z) {
00059     comp[X] = x; comp[Y] = y; comp[Z] = z;
00060   }
00061 
00062 protected:
00063   Scalar comp[3];                            
00064 };
00065 
00066 inline bool operator==(const Tuple3& t1, const Tuple3& t2) {
00067   return t1[X] == t2[X] && t1[Y] == t2[Y] && t1[Z] == t2[Z];
00068 }
00069 
00070 inline ostream& operator<<(ostream& os, const Tuple3& t) {
00071   return os << t[X] << ' ' << t[Y] << ' ' << t[Z];
00072 }
00073 
00074 #endif

Generated at Thu Feb 26 21:52:31 2004 for torcs by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-1999
TORCS © Eric Espié 1999, 2002.