65 return X == 0.0 &&
Y == 0.0 &&
Z == 0.0;
189 return a.
X * b.
X + a.
Y * b.
Y + a.
Z * b.
Z;
202 return Vec3D(std::max(a.
X, b.
X), std::max(a.
Y, b.
Y), std::max(a.
Z, b.
Z));
215 return Vec3D(std::min(a.
X, b.
X), std::min(a.
Y, b.
Y), std::min(a.
Z, b.
Z));
258 return Vec3D(std::sqrt(a.
X), std::sqrt(a.
Y), std::sqrt(a.
Z));
270 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);
295 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));
306 return (a.
X * a.
X + a.
Y * a.
Y + a.
Z * a.
Z);
315 return (
X *
X +
Y *
Y +
Z *
Z);
334 logger(
ERROR,
"[Vector::getComponent] Index = %, which is too high for a 3D vector (should be 0-2).", index);
359 logger(
ERROR,
"[Vector::setComponent] Index = %, which is too high for a 3D vector (should be 0-2).", index);
369 return Vec3D(std::sqrt(
X *
X +
Y *
Y), std::atan2(Y,
X),
Z);
378 return Vec3D(
X * std::cos(
Y),
X * std::sin(
Y),
Z);
445 return a / std::sqrt(Length2);
447 return Vec3D(0, 0, 0);
459 os << a.
X <<
' ' << a.
Y <<
' ' << a.
Z;
472 is >> a.
X >> a.
Y >> a.
Z;
486 return Vec3D(b.
X + a, b.
Y + a, b.
Z + a);
499 return Vec3D(a - b.
X, a - b.
Y, a - b.
Z);
524 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")
Vec3D operator-(const Mdouble a, const Vec3D &b)
void normalize()
Makes this Vec3D unit length.
void setLength(Mdouble length)
Make this Vec3D a certain length.
Vec3D operator*(const Mdouble a) const
Multiplies by 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 Mdouble a, const Vec3D &b)
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.