TORCS  1.3.9
The Open Racing Car Simulator
Tuple4.h
Go to the documentation of this file.
1 /*
2  3D - C++ Class Library for 3D Transformations
3  Copyright (C) 1996-1998 Gino van den Bergen
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Library General Public License for more details.
14 
15  You should have received a copy of the GNU Library General Public
16  License along with this library; if not, write to the Free
17  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 
19  Please send remarks, questions and bug reports to gino@win.tue.nl,
20  or write to:
21  Gino van den Bergen
22  Department of Mathematics and Computing Science
23  Eindhoven University of Technology
24  P.O. Box 513, 5600 MB Eindhoven, The Netherlands
25 */
26 
27 #ifndef _TUPLE4_H_
28 #define _TUPLE4_H_
29 
30 #include "Basic.h"
31 
32 #include <assert.h>
33 #include <iostream>
34 
35 using namespace std;
36 
37 class Tuple4 {
38 public:
39  Tuple4() {}
40  Tuple4(const float v[4]) { setValue(v); }
41  Tuple4(const double v[4]) { setValue(v); }
42  Tuple4(Scalar x, Scalar y, Scalar z, Scalar w) { setValue(x, y, z, w); }
43 
44  Scalar& operator[](int i) { return comp[i]; }
45  const Scalar& operator[](int i) const { return comp[i]; }
46 
47  Scalar *getValue() { return comp; }
48  const Scalar *getValue() const { return comp; }
49 
50  void setValue(const float v[4]) {
51  comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; comp[W] = v[W];
52  }
53 
54  void setValue(const double v[4]) {
55  comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; comp[W] = v[W];
56  }
57 
58  void setValue(Scalar x, Scalar y, Scalar z, Scalar w) {
59  comp[X] = x; comp[Y] = y; comp[Z] = z; comp[W] = w;
60  }
61 
62 protected:
63  Scalar comp[4];
64 };
65 
66 inline bool operator==(const Tuple4& t1, const Tuple4& t2) {
67  return t1[X] == t2[X] && t1[Y] == t2[Y] && t1[Z] == t2[Z] && t1[W] == t2[W];
68 }
69 
70 inline ostream& operator<<(ostream& os, const Tuple4& t) {
71  return os << t[X] << ' ' << t[Y] << ' ' << t[Z] << ' ' << t[W];
72 }
73 
74 #endif
Definition: Basic.h:58
Tuple4(const double v[4])
Definition: Tuple4.h:41
Definition: Tuple4.h:37
Definition: Basic.h:58
void setValue(Scalar x, Scalar y, Scalar z, Scalar w)
Definition: Tuple4.h:58
Definition: Basic.h:58
bool operator==(const Tuple4 &t1, const Tuple4 &t2)
Definition: Tuple4.h:66
const Scalar & operator[](int i) const
Definition: Tuple4.h:45
Scalar * getValue()
Definition: Tuple4.h:47
Tuple4()
Definition: Tuple4.h:39
Definition: Basic.h:58
Tuple4(const float v[4])
Definition: Tuple4.h:40
Tuple4(Scalar x, Scalar y, Scalar z, Scalar w)
Definition: Tuple4.h:42
static Vector y[4]
Definition: Convex.cpp:56
#define Scalar
Definition: Basic.h:34
Scalar & operator[](int i)
Definition: Tuple4.h:44
ostream & operator<<(ostream &os, const Tuple4 &t)
Definition: Tuple4.h:70
void setValue(const float v[4])
Definition: Tuple4.h:50
void setValue(const double v[4])
Definition: Tuple4.h:54
const Scalar * getValue() const
Definition: Tuple4.h:48