66 return std::isnan(
X) || std::isnan(
Y) || std::isnan(
Z);
78 return a.
X * b.
X + a.
Y * b.
Y + a.
Z * b.
Z;
91 return Vec3D(std::max(a.
X, b.
X), std::max(a.
Y, b.
Y), std::max(a.
Z, b.
Z));
104 return Vec3D(std::min(a.
X, b.
X), std::min(a.
Y, b.
Y), std::min(a.
Z, b.
Z));
130 *
this /= std::sqrt(length2);
153 return Vec3D(std::sqrt(a.
X), std::sqrt(a.
Y), std::sqrt(a.
Z));
165 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);
186 return (
X *
X +
Y *
Y +
Z *
Z);
205 logger(
ERROR,
"[Vector::getComponent] Index = %, which is too high for a 3D vector (should be 0-2).",
231 logger(
ERROR,
"[Vector::setComponent] Index = %, which is too high for a 3D vector (should be 0-2).",
239 return X *
X +
Y *
Y;
244 return std::sqrt(
X *
X +
Y *
Y);
253 return Vec3D(std::sqrt(
X *
X +
Y *
Y), std::atan2(Y,
X),
Z);
272 return Vec3D(
X * c +
Y * s, -
X * s +
Y * c,
Z);
349 return a / std::sqrt(Length2);
351 return Vec3D(0, 0, 0);
363 os << a.
X <<
' ' << a.
Y <<
' ' << a.
Z;
377 is >> a.
X; is.clear();
378 is >> a.
Y; is.clear();
Vec3D getCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
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 cylindrical coordinates.
std::istream & operator>>(std::istream &is, Vec3D &a)
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
void normalise()
Makes this Vec3D unit length.
bool isNaN() const
Checks if ALL elements are zero.
void setLength(Mdouble length)
Make this Vec3D a certain length.
Implementation of a 3D vector (by Vitaliy).
Vec3D getCylindricalTensorField(const Vec3D &position) const
Returns this vector field at point p to cylindrical coordinates.
void setZero()
Sets all elements to zero.
Mdouble getRadialCoordinate() const
Returns the square of the radial cylindrical coordinate, r=sqrt(x^2+y^2).
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: .
static Vec3D square(const Vec3D &a)
Calculates the pointwise square of a Vec3D.
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Mdouble getRadialCoordinateSquared() const
Returns the square of the radial cylindrical coordinate, r^2=x^2+y^2.
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Mdouble getComponent(int index) const
Returns the requested component of this 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: .
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Mdouble getLength() const
Calculates the length of this Vec3D: .
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
bool isEqualTo(const Vec3D &other, double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
void setNaN()
Sets all elements to NaN.
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.