TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
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
35using namespace std;
36
37class Tuple4 {
38public:
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
59 comp[X] = x; comp[Y] = y; comp[Z] = z; comp[W] = w;
60 }
61
62protected:
64};
65
66inline 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
70inline ostream& operator<<(ostream& os, const Tuple4& t) {
71 return os << t[X] << ' ' << t[Y] << ' ' << t[Z] << ' ' << t[W];
72}
73
74#endif
@ Y
Definition Basic.h:58
@ X
Definition Basic.h:58
@ Z
Definition Basic.h:58
@ W
Definition Basic.h:58
#define Scalar
Definition Basic.h:34
static Vector y[4]
Definition Convex.cpp:56
bool operator==(const Tuple4 &t1, const Tuple4 &t2)
Definition Tuple4.h:66
ostream & operator<<(ostream &os, const Tuple4 &t)
Definition Tuple4.h:70
void setValue(const double v[4])
Definition Tuple4.h:54
Tuple4(Scalar x, Scalar y, Scalar z, Scalar w)
Definition Tuple4.h:42
const Scalar * getValue() const
Definition Tuple4.h:48
void setValue(Scalar x, Scalar y, Scalar z, Scalar w)
Definition Tuple4.h:58
void setValue(const float v[4])
Definition Tuple4.h:50
Tuple4(const float v[4])
Definition Tuple4.h:40
Scalar * getValue()
Definition Tuple4.h:47
Tuple4(const double v[4])
Definition Tuple4.h:41
const Scalar & operator[](int i) const
Definition Tuple4.h:45
Tuple4()
Definition Tuple4.h:39
Scalar comp[4]
Definition Tuple4.h:63
Scalar & operator[](int i)
Definition Tuple4.h:44