 |
revision: v0.14
|
Go to the documentation of this file.
42 template<
unsigned int N>
103 {
return X == 0.0 &&
Y == 0.0 &&
Z == 0.0; }
183 return X>=a.
X &&
Y>=a.
Y &&
Z>=a.
Z;
187 return X<a.
X &&
Y<a.
Y &&
Z<a.
Z;
249 static double max(
const Vec3D& a) {
return std::max(std::max(a.
X,a.
Y),a.
Z);}
254 static double min(
const Vec3D& a) {
return std::min(std::min(a.
X,a.
Y),a.
Z);}
296 const double X = a.
X-b.
X;
297 const double Y = a.
Y-b.
Y;
298 const double Z = a.
Z-b.
Z;
299 return (
X *
X +
Y *
Y +
Z *
Z);
318 return (a.
X * a.
X + a.
Y * a.
Y + a.
Z * a.
Z);
464 return Vec3D(b.
X * a, b.
Y * a, b.
Z * a);
bool isEqualTo(const Vec3D &other, double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Definition: Vector.cc:294
Vec3D operator+(const Vec3D &a) const
Adds another vector.
Definition: Vector.h:116
void setLength(Mdouble length)
Make this Vec3D a certain length.
Definition: Vector.cc:138
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:345
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Vector.h:132
bool isNaN() const
Checks if ALL elements are zero.
Definition: Vector.cc:64
void setZero()
Sets all elements to zero.
Definition: Vector.cc:43
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:123
Vec3D getFromCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
Definition: Vector.cc:279
void setX(Mdouble x)
Definition: Vector.h:377
Vec3D()
constructor
Definition: Vector.h:70
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
Mdouble y() const
RO reference to Y.
Definition: Vector.h:362
Vec3D(const Mdouble x, const Mdouble y, const Mdouble z)
Alternative constructor, taking the three elements as arguments.
Definition: Vector.h:82
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Mdouble X
the vector components
Definition: Vector.h:65
void setY(Mdouble y)
Definition: Vector.h:380
Vec3D divideElementwise(const Vec3D &a) const
Definition: Vector.h:136
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble getRadialCoordinateSquared() const
Returns the square of the radial cylindrical coordinate, r^2=x^2+y^2.
Definition: Vector.cc:237
friend Vec3D operator-(const Vec3D &a)
Reverts the direction of a vector.
Definition: Vector.h:450
std::istream & operator>>(std::istream &is, Vec3D &a)
Definition: Vector.cc:374
int main()
Definition: Vec3DUnitTest.cpp:30
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
void check(double real, double ideal, double error, std::string errorMessage)
Definition: Helpers.cc:911
Vec3D & operator+=(const Vec3D &a)
Adds another vector.
Definition: Vector.h:171
friend Vec3D operator*(Mdouble a, const Vec3D &b)
Multiplies all elements by a scalar.
Definition: Vector.h:463
static Vec3D square(const Vec3D &a)
Calculates the pointwise square of a Vec3D.
Definition: Vector.cc:114
friend std::istream & operator>>(std::istream &is, Vec3D &a)
Adds elements to an input stream.
Definition: Vector.cc:374
double Mdouble
Definition: GeneralDefine.h:34
Mdouble getLength() const
Calculates the length of this Vec3D: .
Definition: Vector.cc:320
static Vec3D sqrt(const Vec3D &a)
Calculates the pointwise square root of a Vec3D.
Definition: Vector.cc:151
Mdouble getY()
Definition: Vector.h:389
Mdouble z() const
RO reference to Z.
Definition: Vector.h:374
Vec3D operator-(const Vec3D a) const
Binary vector subtraction.
Definition: Vector.h:127
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Definition: Vector.cc:217
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
Vec3D & operator*=(Mdouble a)
Multiplies by a scalar.
Definition: Vector.h:210
Mdouble sin(Mdouble x)
Definition: ExtendedMath.cc:44
Mdouble & z()
RW reference to Z.
Definition: Vector.h:368
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
Mdouble & x()
RW reference to X.
Definition: Vector.h:344
Mdouble getRadialCoordinate() const
Returns the square of the radial cylindrical coordinate, r=sqrt(x^2+y^2).
Definition: Vector.cc:242
Vec3D signedSquare() const
Definition: Vector.h:140
Vec3D operator*(const Mdouble a) const
Multiplies by a scalar.
Definition: Vector.h:150
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:175
Vec3D & operator-=(const Vec3D &a)
Subtracts another vector.
Definition: Vector.h:196
Mdouble getX()
Definition: Vector.h:386
Vec3D getCylindricalTensorField(const Vec3D &position) const
Returns this vector field at point p to cylindrical coordinates.
Definition: Vector.cc:261
std::ostream & operator<<(std::ostream &os, const Vec3D &a)
Definition: Vector.cc:361
Vec3D & operator/=(const Mdouble a)
Divides by a scalar.
Definition: Vector.h:223
void set(Mdouble x, Mdouble y, Mdouble z)
Definition: Vector.h:395
Mdouble Y
Definition: Vector.h:65
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:102
bool operator<(const Vec3D &a) const
Definition: Vector.h:186
Mdouble & y()
RW reference to Y.
Definition: Vector.h:356
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
bool operator>=(const Vec3D &a) const
Checks if all coordinates satisfy this>=a.
Definition: Vector.h:182
Vec3D getCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
Definition: Vector.cc:251
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
Mdouble x() const
RO reference to X.
Definition: Vector.h:350
void setZ(Mdouble z)
Definition: Vector.h:383
Mdouble getZ()
Definition: Vector.h:392
Vec3D operator/(Mdouble a) const
Divides by a scalar.
Definition: Vector.h:161
const Mdouble NaN
Definition: GeneralDefine.h:43
static double max(const Vec3D &a)
Calculates the maximum coordinate of vector a.
Definition: Vector.h:249
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.h:295
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.
Definition: Vector.cc:89
Mdouble Z
Definition: Vector.h:65
void setNaN()
Sets all elements to NaN.
Definition: Vector.cc:53
friend std::ostream & operator<<(std::ostream &os, const Vec3D &a)
Adds elements to an output stream.
Definition: Vector.cc:361
Definition: SmallVector.h:62
static double min(const Vec3D &a)
Calculates the minimum coordinate of vector a.
Definition: Vector.h:254
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:184
Mdouble cos(Mdouble x)
Definition: ExtendedMath.cc:64
bool isZero() const
Checks if ALL elements are zero.
Definition: Vector.h:102