Template class for 3-vectors of type float, double, …
Allows accessing and changing the elements x, y, z directly or through the corresponding get and set methods.
Angle definitions are phi [-pi, pi]: azimuthal angle in the x-y plane, 0 pointing in x-direction theta [0, pi]: zenith angle towards the z axis, 0 pointing in z-direction
Public Functions
-
inline Vector3()
-
inline Vector3(const Vector3 &v)
-
template<typename U>
inline Vector3(const Vector3<U> &v)
-
inline ~Vector3()
-
inline explicit Vector3(const double *v)
-
inline explicit Vector3(const float *v)
-
inline explicit Vector3(const T &X, const T &Y, const T &Z)
-
inline explicit Vector3(T t)
-
inline void setX(const T X)
-
inline void setY(const T Y)
-
inline void setZ(const T Z)
-
inline void setXYZ(const T X, const T Y, const T Z)
-
inline void setR(const T r)
-
inline void setRThetaPhi(const T r, const T theta, const T phi)
-
inline T getX() const
-
inline T getY() const
-
inline T getZ() const
-
inline T getR() const
magnitude (2-norm) of the vector
-
inline T getR2() const
square of magnitude of the vector
-
inline T getPhi() const
return the azimuth angle
-
inline T getTheta() const
return the zenith angle
-
inline Vector3<T> getUnitVector() const
return the unit-vector e_r
-
inline Vector3<T> getUnitVectorTheta() const
return the unit-vector e_theta
-
inline Vector3<T> getUnitVectorPhi() const
return the unit-vector e_phi
-
inline T getAngleTo(const Vector3<T> &v) const
return the angle [0, pi] between the vectors
-
inline bool isParallelTo(const Vector3<T> &v, T maxAngle) const
return true if the angle between the vectors is smaller than a threshold
-
inline T getDistanceTo(const Vector3<T> &point) const
linear distance to a given vector
-
inline Vector3<T> getParallelTo(const Vector3<T> &v) const
return the component parallel to a second vector 0 if the second vector has 0 magnitude
-
inline Vector3<T> getPerpendicularTo(const Vector3<T> &v) const
return the component perpendicular to a second vector 0 if the second vector has 0 magnitude
-
inline Vector3<T> getRotated(const Vector3<T> &axis, T angle) const
rotate the vector around a given axis by a given angle
-
inline Vector3<T> clip(T lower, T upper) const
return vector with values limited to the range [lower, upper]
-
inline Vector3<T> abs() const
return vector with absolute values
-
inline Vector3<T> floor() const
return vector with floored values
-
inline Vector3<T> ceil() const
return vector with ceiled values
-
inline T min() const
minimum element
-
inline T max() const
maximum element
-
inline T dot(const Vector3<T> &v) const
dot product
-
inline Vector3<T> cross(const Vector3<T> &v) const
cross product
-
inline bool operator==(const Vector3<T> &v) const
returns true if all elements of the two vectors are equal
-
inline Vector3<T> operator+(const Vector3<T> &v) const
-
inline Vector3<T> operator+(const T &f) const
-
inline Vector3<T> operator-(const Vector3<T> &v) const
-
inline Vector3<T> operator-(const T &f) const
-
inline Vector3<T> operator*(const Vector3<T> &v) const
element-wise multiplication
-
inline Vector3<T> operator*(T v) const
-
inline Vector3<T> operator/(const Vector3<T> &v) const
element-wise division
-
inline Vector3<T> operator/(const T &f) const
-
inline Vector3<T> operator%(const Vector3<T> &v) const
element-wise modulo operation
-
inline Vector3<T> operator%(const T &f) const
-
inline Vector3<T> &operator-=(const Vector3<T> &v)
-
inline Vector3<T> &operator-=(const T &f)
-
inline Vector3<T> &operator+=(const Vector3<T> &v)
-
inline Vector3<T> &operator+=(const T &f)
-
inline Vector3<T> &operator*=(const Vector3<T> &v)
element-wise multiplication
-
inline Vector3<T> &operator*=(const T &f)
-
inline Vector3<T> &operator/=(const Vector3<T> &v)
element-wise division
-
inline Vector3<T> &operator/=(const T &f)
-
inline Vector3<T> &operator%=(const Vector3<T> &v)
element-wise modulo operation
-
inline Vector3<T> &operator%=(const T &f)
-
inline Vector3<T> &operator=(const Vector3<T> &v)
-
inline Vector3<T> &operator=(const T &f)
-
inline const std::string getDescription()
-
inline PyObject *__array__()
-
inline size_t __len__()
-
inline Vector3(PyObject *inputObject)
initialize the vector from a numpy array
Public Members
-
T x
-
T y
-
T z
-
T data[3]
-
union crpropa::Vector3