00001 #ifndef Impala_Core_Array_Element_Vec3Real64_h
00002 #define Impala_Core_Array_Element_Vec3Real64_h
00003
00004 #include <iostream>
00005 #include "Util/Math.h"
00006 #include "Basis/NativeTypes.h"
00007
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace Array
00013 {
00014 namespace Element
00015 {
00016
00017
00020 class Vec3Real64 {
00021 public:
00022
00024 Vec3Real64()
00025 {
00026 }
00027
00029 Vec3Real64(Real64 x, Real64 y, Real64 z)
00030 {
00031 mValues[0] = x;
00032 mValues[1] = y;
00033 mValues[2] = z;
00034 }
00035
00037 Vec3Real64(Real64 v)
00038 {
00039 mValues[0] = v;
00040 mValues[1] = v;
00041 mValues[2] = v;
00042 }
00043
00045 Vec3Real64(const Vec3Real64& v)
00046 {
00047 mValues[0] = v.mValues[0];
00048 mValues[1] = v.mValues[1];
00049 mValues[2] = v.mValues[2];
00050 }
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00063 Real64
00064 X() const
00065 {
00066 return mValues[0];
00067 }
00068
00070 Real64
00071 Y() const
00072 {
00073 return mValues[1];
00074 }
00075
00077 Real64
00078 Z() const
00079 {
00080 return mValues[2];
00081 }
00082
00084 Real64
00085 getValue(int dimension) const
00086 {
00087 return mValues[dimension - 1];
00088 }
00089
00091 int
00092 operator==(const Vec3Real64& v) const
00093 {
00094 return (mValues[0] == v.mValues[0]) && (mValues[1] == v.mValues[1]) &&
00095 (mValues[2] == v.mValues[2]);
00096 }
00097
00099 int
00100 operator!=(const Vec3Real64& v) const
00101 {
00102 return (mValues[0] != v.mValues[0]) || (mValues[1] != v.mValues[1]) ||
00103 (mValues[2] != v.mValues[2]);
00104 }
00105
00107 int
00108 operator<(const Vec3Real64& v) const
00109 {
00110 return (fabs(mValues[0]) + fabs(mValues[1]) + fabs(mValues[2])) <
00111 (fabs(v.mValues[0]) + fabs(v.mValues[1]) + fabs(v.mValues[2]));
00112 }
00113
00115 int
00116 operator<=(const Vec3Real64& v) const
00117 {
00118 return (fabs(mValues[0]) + fabs(mValues[1]) + fabs(mValues[2])) <=
00119 (fabs(v.mValues[0]) + fabs(v.mValues[1]) + fabs(v.mValues[2]));
00120 }
00121
00123 int
00124 operator> (const Vec3Real64& v) const
00125 {
00126 return (fabs(mValues[0]) + fabs(mValues[1]) + fabs(mValues[2])) >
00127 (fabs(v.mValues[0]) + fabs(v.mValues[1]) + fabs(v.mValues[2]));
00128 }
00129
00131 int
00132 operator>=(const Vec3Real64& v) const
00133 {
00134 return (fabs(mValues[0]) + fabs(mValues[1]) + fabs(mValues[2])) >=
00135 (fabs(v.mValues[0]) + fabs(v.mValues[1]) + fabs(v.mValues[2]));
00136 }
00137
00139 Vec3Real64&
00140 operator+=(const Vec3Real64& v)
00141 {
00142 mValues[0] += v.mValues[0];
00143 mValues[1] += v.mValues[1];
00144 mValues[2] += v.mValues[2];
00145 return *this;
00146 }
00147
00149 Vec3Real64&
00150 operator-=(const Vec3Real64& v)
00151 {
00152 mValues[0] -= v.mValues[0];
00153 mValues[1] -= v.mValues[1];
00154 mValues[2] -= v.mValues[2];
00155 return *this;
00156 }
00157
00159 Vec3Real64&
00160 operator*=(const Vec3Real64& v)
00161 {
00162 mValues[0] *= v.mValues[0];
00163 mValues[1] *= v.mValues[1];
00164 mValues[2] *= v.mValues[2];
00165 return *this;
00166 }
00167
00169 Vec3Real64&
00170 operator*=(double v)
00171 {
00172 mValues[0] *= v;
00173 mValues[1] *= v;
00174 mValues[2] *= v;
00175 return *this;
00176 }
00177
00179 Vec3Real64&
00180 operator/=(const Vec3Real64& v)
00181 {
00182 mValues[0] /= v.mValues[0];
00183 mValues[1] /= v.mValues[1];
00184 mValues[2] /= v.mValues[2];
00185 return *this;
00186 }
00187
00189 Vec3Real64&
00190 operator/=(double d)
00191 {
00192 mValues[0] /= d;
00193 mValues[1] /= d;
00194 mValues[2] /= d;
00195 return *this;
00196 }
00197
00198 private:
00199 Real64 mValues[3];
00200 };
00201
00202 inline std::ostream&
00203 operator<<(std::ostream& os, const Vec3Real64& v)
00204 {
00205 return os << "(" << v.X() << "," << v.Y() << "," << v.Z() << ")";
00206 }
00207
00208 inline Vec3Real64
00209 operator+(const Vec3Real64& v1, const Vec3Real64& v2)
00210 {
00211 return Vec3Real64(v1.X() + v2.X(), v1.Y() + v2.Y(), v1.Z() + v2.Z());
00212 }
00213
00214 inline Vec3Real64
00215 operator-(const Vec3Real64& v1, const Vec3Real64& v2)
00216 {
00217 return Vec3Real64(v1.X() - v2.X(), v1.Y() - v2.Y(), v1.Z() - v2.Z());
00218 }
00219
00220 inline Vec3Real64
00221 operator*(const Vec3Real64& v1, const Vec3Real64& v2)
00222 {
00223 return Vec3Real64(v1.X() * v2.X(), v1.Y() * v2.Y(), v1.Z() * v2.Z());
00224 }
00225
00226 inline Vec3Real64
00227 operator*(const Vec3Real64& v1, double d)
00228 {
00229 return Vec3Real64(v1.X() * d, v1.Y() * d, v1.Z() * d);
00230 }
00231
00232 inline Vec3Real64
00233 operator/(const Vec3Real64& v1, const Vec3Real64& v2)
00234 {
00235 return Vec3Real64(v1.X() / v2.X(), v1.Y() / v2.Y(), v1.Z() / v2.Z());
00236 }
00237
00238 inline Vec3Real64
00239 operator/(const Vec3Real64& v1, double d)
00240 {
00241 return Vec3Real64(v1.X() / d, v1.Y() / d, v1.Z() / d);
00242 }
00243
00244 }
00245 }
00246 }
00247 }
00248
00249 #endif