00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef _TUPLE4_H_
00028 #define _TUPLE4_H_
00029
00030 #include "Basic.h"
00031
00032 #include <assert.h>
00033 #include <iostream>
00034
00035 using namespace std;
00036
00037 class Tuple4 {
00038 public:
00039 Tuple4() {}
00040 Tuple4(const float v[4]) { setValue(v); }
00041 Tuple4(const double v[4]) { setValue(v); }
00042 Tuple4(Scalar x, Scalar y, Scalar z, Scalar w) { setValue(x, y, z, w); }
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[4]) {
00051 comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; comp[W] = v[W];
00052 }
00053
00054 void setValue(const double v[4]) {
00055 comp[X] = v[X]; comp[Y] = v[Y]; comp[Z] = v[Z]; comp[W] = v[W];
00056 }
00057
00058 void setValue(Scalar x, Scalar y, Scalar z, Scalar w) {
00059 comp[X] = x; comp[Y] = y; comp[Z] = z; comp[W] = w;
00060 }
00061
00062 protected:
00063 Scalar comp[4];
00064 };
00065
00066 inline bool operator==(const Tuple4& t1, const Tuple4& t2) {
00067 return t1[X] == t2[X] && t1[Y] == t2[Y] && t1[Z] == t2[Z] && t1[W] == t2[W];
00068 }
00069
00070 inline ostream& operator<<(ostream& os, const Tuple4& t) {
00071 return os << t[X] << ' ' << t[Y] << ' ' << t[Z] << ' ' << t[W];
00072 }
00073
00074 #endif