29 inline Vec3 operator*(
const double lhs,
const Vec3 rhs);
30 inline Vec3 operator*(
const Vec3 lhs,
const double rhs);
31 inline Vec3 operator*(
const Vec3 lhs,
const int rhs);
32 inline Vec3 operator*(
const int lhs,
const Vec3 rhs);
41 : x(
std::numeric_limits<double>::quiet_NaN())
42 , y(
std::numeric_limits<double>::quiet_NaN())
43 ,
z(
std::numeric_limits<double>::quiet_NaN())
46 Vec3(
double xin,
double yin,
double zin) : x(xin), y(yin),
z(zin)
50 Vec3(
const double in[3]) : x(in[0]), y(in[1]),
z(in[2])
73 return std::numeric_limits<double>::quiet_NaN();
92 x = y =
z = std::numeric_limits<double>::quiet_NaN();
99 return x * rhs.x + y * rhs.y +
z * rhs.
z;
105 return Vec3(y * rhs.
z -
z * rhs.y,
z * rhs.x - x * rhs.
z, x * rhs.y - y * rhs.x);
111 return this->
Dot(*
this);
127 inline Vec3 &operator=(
const Vec3 &other)
138 inline Vec3 operator+(
const Vec3 rhs)
const
140 return Vec3(x + rhs.x, y + rhs.y,
z + rhs.z);
142 inline Vec3 operator-(
const Vec3 rhs)
const
144 return Vec3(x - rhs.x, y - rhs.y,
z - rhs.z);
146 inline Vec3 operator/(
const double rhs)
const
148 return Vec3(x / rhs, y / rhs,
z / rhs);
150 inline Vec3 operator+()
const
154 inline Vec3 operator-()
const
156 return (*
this) * double(-1);
159 inline Vec3 operator+=(
const Vec3 rhs)
161 (*this) = (*this) + rhs;
164 inline Vec3 operator-=(
const Vec3 rhs)
166 (*this) = (*this) - rhs;
169 inline Vec3 operator*=(
const double &rhs)
171 *
this = (*this) * rhs;
174 inline Vec3 operator/=(
const double &rhs)
176 *
this = (*this) / rhs;
182 inline Vec3 operator*(
const double lhs,
const Vec3 rhs)
184 return Vec3(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
186 inline Vec3 operator*(
const Vec3 lhs,
const double rhs)
188 return Vec3(lhs.x * rhs, lhs.y * rhs, lhs.z * rhs);
192 inline Vec3 operator*(
const Vec3 lhs,
const int rhs)
194 return Vec3(rhs * lhs.x, rhs * lhs.y, rhs * lhs.z);
197 inline Vec3 operator*(
const int lhs,
const Vec3 rhs)
199 return Vec3(lhs * rhs.x, lhs * rhs.y, lhs * rhs.z);
3D vector class with common vector operations.
Vec3(Vec3 const &in)
Initialise from Vec3.
double GetNorm2Squared(void) const
Calculate the Euclidean norm of the vector, squared (= sum of squared elements).
Vec3 GetUnitVector(void) const
Get the unit vector pointing along the same direction as this vector. Will fail for zero vectors.
double operator[](int i) const
Getter function, index 0 <-> x, 1 <-> y, 2 <-> z.
double & operator[](int i)
Setter function, index 0 <-> x, 1 <-> y, 2 <-> z.
Vec3 Cross(const Vec3 rhs) const
Calculate the cross product of two vectors.
double GetNorm2(void) const
Calculate the Euclidean norm of the vector.
Vec3(double xin, double yin, double zin)
Initialise vector.
Vec3(const double in[3])
Initialise vector.
double z
the three components of the vector
Vec3(void)
Initialises all members to NaN.
double Dot(const Vec3 rhs) const
Calculate the dot product of two vectors.