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);
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.
friend Vec3D operator-(const Vec3D &a)
Reverts the direction of a vector.
Vec3D getFromCylindricalCoordinates() const
Returns the representation of this Vec3D in cylindrical coordinates.
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.
Vec3D multiplyElementwise(const Vec3D &a) const
Vec3D operator*(const Mdouble a) const
Multiplies by a scalar.
Mdouble z() const
RO reference to Z.
Vec3D(const Mdouble x, const Mdouble y, const Mdouble z)
Alternative constructor, taking the three elements as arguments.
Implementation of a 3D vector (by Vitaliy).
Mdouble y() const
RO reference to Y.
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: .
Vec3D divideElementwise(const Vec3D &a) const
static Vec3D square(const Vec3D &a)
Calculates the pointwise square of a Vec3D.
Vec3D & operator*=(Mdouble a)
Multiplies by a scalar.
bool isZero() const
Checks if ALL elements are zero.
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Mdouble & z()
RW reference to Z.
void setComponent(int index, double val)
Sets the requested component of this Vec3D to the requested value.
friend Vec3D operator*(Mdouble a, const Vec3D &b)
Multiplies all elements by a scalar.
Vec3D operator+(const Vec3D &a) const
Adds another vector.
Vec3D operator/(Mdouble a) const
Divides by a scalar.
Mdouble getRadialCoordinateSquared() const
Returns the square of the radial cylindrical coordinate, r^2=x^2+y^2.
Vec3D & operator/=(const Mdouble a)
Divides by a scalar.
bool operator<(const Vec3D &a) const
Vec3D & operator+=(const Vec3D &a)
Adds another vector.
Vec3D & operator-=(const Vec3D &a)
Subtracts another vector.
static Vec3D min(const Vec3D &a, const Vec3D &b)
Calculates the pointwise minimum of two Vec3D.
friend std::istream & operator>>(std::istream &is, Vec3D &a)
Adds elements to an input stream.
Mdouble getComponent(int index) const
Returns the requested component of this Vec3D.
Mdouble & x()
RW reference to X.
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Mdouble x() const
RO reference to X.
static Vec3D cross(const Vec3D &a, const Vec3D &b)
Calculates the cross product of two Vec3D: .
Mdouble & y()
RW reference to Y.
static Mdouble getDistanceSquared(const Vec3D &a, const Vec3D &b)
Calculates the squared distance between two Vec3D: .
Vec3D operator-(const Vec3D a) const
Binary vector subtraction.
Mdouble getLength() const
Calculates the length of this Vec3D: .
void set(Mdouble x, Mdouble y, Mdouble z)
static double max(const Vec3D &a)
Calculates the maximum coordinate of vector a.
bool operator>=(const Vec3D &a) const
Checks if all coordinates satisfy this>=a.
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
static double min(const Vec3D &a)
Calculates the minimum coordinate of vector 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.
Vec3D signedSquare() const
void setNaN()
Sets all elements to NaN.
friend std::ostream & operator<<(std::ostream &os, const Vec3D &a)
Adds elements to an output stream.
static Vec3D max(const Vec3D &a, const Vec3D &b)
Calculates the pointwise maximum of two Vec3D.