31 #ifndef MECURYDPM_VECTOR_H
32 #define MECURYDPM_VECTOR_H
43 template<
unsigned int N>
114 {
return X == 0.0 &&
Y == 0.0 &&
Z == 0.0; }
145 return X == a.
X and
Y == a.
Y and
Z == a.
Z;
199 return X>=a.
X &&
Y>=a.
Y &&
Z>=a.
Z;
203 return X<a.
X &&
Y<a.
Y &&
Z<a.
Z;
265 static double max(
const Vec3D& a) {
return std::max(std::max(a.
X,a.
Y),a.
Z);}
270 static double min(
const Vec3D& a) {
return std::min(std::min(a.
X,a.
Y),a.
Z);}
312 const double X = a.
X-b.
X;
313 const double Y = a.
Y-b.
Y;
314 const double Z = a.
Z-b.
Z;
315 return (
X *
X +
Y *
Y +
Z *
Z);
334 return (a.
X * a.
X + a.
Y * a.
Y + a.
Z * a.
Z);
480 return Vec3D(b.
X * a, b.
Y * a, b.
Z * a);
double Mdouble
Definition: GeneralDefine.h:34
Definition: SmallVector.h:62
Mdouble & y()
RW reference to Y.
Definition: Vector.h:372
Mdouble Y
Definition: Vector.h:66
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
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:175
Vec3D getCylindricalTensorField(const Vec3D &position) const
Returns this vector field at point p to cylindrical coordinates.
Definition: Vector.cc:261
Vec3D operator/(Mdouble a) const
Divides by a scalar.
Definition: Vector.h:177
Vec3D operator*(const Mdouble a) const
Multiplies by a scalar.
Definition: Vector.h:166
Mdouble Z
Definition: Vector.h:66
Mdouble & z()
RW reference to Z.
Definition: Vector.h:384
Vec3D divideElementwise(const Vec3D &a) const
Definition: Vector.h:152
Mdouble getRadialCoordinateSquared() const
Returns the square of the radial cylindrical coordinate, r^2=x^2+y^2.
Definition: Vector.cc:237
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.
Definition: Vector.cc:89
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
Definition: Vector.cc:102
Mdouble y() const
RO reference to Y.
Definition: Vector.h:378
void setNaN()
Sets all elements to NaN.
Definition: Vector.cc:53
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:332
Vec3D & operator+=(const Vec3D &a)
Adds another vector.
Definition: Vector.h:187
bool operator==(const Vec3D &a) const
Definition: Vector.h:143
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Definition: Vector.cc:163
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Definition: Vector.cc:194
Vec3D operator-(const Vec3D a) const
Binary vector subtraction.
Definition: Vector.h:138
Mdouble X
the vector components
Definition: Vector.h:66
Vec3D multiplyElementwise(const Vec3D &a) const
Definition: Vector.h:148
Vec3D & operator-=(const Vec3D &a)
Subtracts another vector.
Definition: Vector.h:212
Vec3D getCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
Definition: Vector.cc:251
friend Vec3D operator-(const Vec3D &a)
Reverts the direction of a vector.
Definition: Vector.h:466
Vec3D()
constructor
Definition: Vector.h:71
bool operator<(const Vec3D &a) const
Definition: Vector.h:202
Vec3D signedSquare() const
Definition: Vector.h:156
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Definition: Vector.h:311
static double min(const Vec3D &a)
Calculates the minimum coordinate of vector a.
Definition: Vector.h:270
bool operator>=(const Vec3D &a) const
Checks if all coordinates satisfy this>=a.
Definition: Vector.h:198
void setZero()
Sets all elements to zero.
Definition: Vector.cc:43
Vec3D(const Mdouble x, const Mdouble y, const Mdouble z)
Alternative constructor, taking the three elements as arguments.
Definition: Vector.h:83
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:184
static double max(const Vec3D &a)
Calculates the maximum coordinate of vector a.
Definition: Vector.h:265
Mdouble getZ() const
Definition: Vector.h:408
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
void set(Mdouble x, Mdouble y, Mdouble z)
Definition: Vector.h:411
void setLength(Mdouble length)
Make this Vec3D a certain length.
Definition: Vector.cc:138
Vec3D(std::array< double, 3 > a)
Definition: Vector.h:93
Mdouble & x()
RW reference to X.
Definition: Vector.h:360
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
Definition: Vector.cc:217
Mdouble getRadialCoordinate() const
Returns the square of the radial cylindrical coordinate, r=sqrt(x^2+y^2).
Definition: Vector.cc:242
Vec3D & operator/=(const Mdouble a)
Divides by a scalar.
Definition: Vector.h:239
bool isNaN() const
Checks if ALL elements are zero.
Definition: Vector.cc:64
void setY(Mdouble y)
Definition: Vector.h:396
friend std::ostream & operator<<(std::ostream &os, const Vec3D &a)
Adds elements to an output stream.
Definition: Vector.cc:361
Mdouble getLength() const
Calculates the length of this Vec3D: .
Definition: Vector.cc:320
Vec3D & operator*=(Mdouble a)
Multiplies by a scalar.
Definition: Vector.h:226
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
Mdouble x() const
RO reference to X.
Definition: Vector.h:366
Mdouble getX() const
Definition: Vector.h:402
Vec3D getFromCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
Definition: Vector.cc:279
void setZ(Mdouble z)
Definition: Vector.h:399
bool isZero() const
Checks if ALL elements are zero.
Definition: Vector.h:113
void normalise()
Makes this Vec3D unit length.
Definition: Vector.cc:123
friend Vec3D operator*(Mdouble a, const Vec3D &b)
Multiplies all elements by a scalar.
Definition: Vector.h:479
static Vec3D getUnitVector(const Vec3D &a)
Returns a unit Vec3D based on a.
Definition: Vector.cc:345
void setX(Mdouble x)
Definition: Vector.h:393
Mdouble z() const
RO reference to Z.
Definition: Vector.h:390
Mdouble getY() const
Definition: Vector.h:405
static Vec3D sqrt(const Vec3D &a)
Calculates the pointwise square root of a Vec3D.
Definition: Vector.cc:151
Vec3D operator+(const Vec3D &a) const
Adds another vector.
Definition: Vector.h:127