65 return X == 0.0 &&
Y == 0.0 &&
Z == 0.0;
169 return a.
X * b.
X + a.
Y * b.
Y + a.
Z * b.
Z;
182 return Vec3D(std::max(a.
X, b.
X), std::max(a.
Y, b.
Y), std::max(a.
Z, b.
Z));
195 return Vec3D(std::min(a.
X, b.
X), std::min(a.
Y, b.
Y), std::min(a.
Z, b.
Z));
221 logger(
WARN,
"Normalizing a vector of length 0");
245 return Vec3D(std::sqrt(a.
X), std::sqrt(a.
Y), std::sqrt(a.
Z));
257 return Vec3D(a.
Y * b.
Z - a.
Z * b.
Y, a.
Z * b.
X - a.
X * b.
Z, a.
X * b.
Y - a.
Y * b.
X);
282 return ((a.
X - b.
X) * (a.
X - b.
X) + (a.
Y - b.
Y) * (a.
Y - b.
Y) + (a.
Z - b.
Z) * (a.
Z - b.
Z));
293 return (a.
X * a.
X + a.
Y * a.
Y + a.
Z * a.
Z);
302 return (
X *
X +
Y *
Y +
Z *
Z);
321 logger(
ERROR,
"[Vector::getComponent] Index = %, which is too high for a 3D vector (should be 0-2).", index);
346 logger(
ERROR,
"[Vector::setComponent] Index = %, which is too high for a 3D vector (should be 0-2).", index);
356 return Vec3D(std::sqrt(
X *
X +
Y *
Y), std::atan2(Y,
X),
Z);
432 return a / std::sqrt(Length2);
434 return Vec3D(0, 0, 0);
446 os << a.
X <<
' ' << a.
Y <<
' ' << a.
Z;
459 is >> a.
X >> a.
Y >> a.
Z;
485 return Vec3D(b.
X * a, b.
Y * a, b.
Z * a);
Vec3D getCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Mdouble X
the vector components
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Vec3D getFromCylindricalCoordinates() const
Returns the representation of this Vec3D in cartesian coordinates.
std::istream & operator>>(std::istream &is, Vec3D &a)
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void normalize()
Makes this Vec3D unit length.
void setLength(Mdouble length)
Make this Vec3D a certain length.
Vec3D operator*(const Mdouble a) const
Adds a scalar.
Vec3D & operator-=(const Vec3D &a)
Subtracts another vector.
Vec3D & operator+=(const Vec3D &a)
Adds another vector.
void setZero()
Sets all elements to zero.
static Vec3D sqrt(const Vec3D &a)
Calculates the pointwise square root of a Vec3D.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Vec3D operator/(const Mdouble a) const
Divides by a scalar.
static Vec3D square(const Vec3D &a)
Calculates the pointwise square of a Vec3D.
bool isEqualTo(const Vec3D &other, const double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
bool isZero() const
Checks if ALL elements are zero.
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Vec3D operator+(const Vec3D &a) const
Adds another vector.
Vec3D operator*(const Mdouble a, const Vec3D &b)
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
std::ostream & operator<<(std::ostream &os, const Vec3D &a)
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
void setComponent(const int index, const double val)
Sets the requested component of this Vec3D to the requested value.
Vec3D & operator/=(const Mdouble a)
Divides by a scalar.
Vec3D operator-(const Vec3D &a)
Mdouble getLength() const
Calculates the length of this Vec3D: .
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Vec3D operator-(const Vec3D &a) const
Subtracts another vector.
Implementation of a 3D vector (by Vitaliy).
Mdouble getComponent(const int index) const
Returns the requested component of this Vec3D.
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.
Vec3D & operator*=(const Mdouble a)
Multiplies by a scalar.