lsst.sphgeom
19.0.0-3-gc70e9ed+1
|
Go to the documentation of this file.
23 #ifndef LSST_SPHGEOM_VECTOR3D_H_
24 #define LSST_SPHGEOM_VECTOR3D_H_
47 Vector3d() { _v[0] = 0.0; _v[1] = 0.0; _v[2] = 0.0; }
50 Vector3d(
double x,
double y,
double z) { _v[0] = x; _v[1] = y; _v[2] = z; }
52 bool operator==(
Vector3d const & v)
const {
53 return _v[0] == v._v[0] && _v[1] == v._v[1] && _v[2] == v._v[2];
56 bool operator!=(
Vector3d const & v)
const {
57 return _v[0] != v._v[0] || _v[1] != v._v[1] || _v[2] != v._v[2];
61 double const *
getData()
const {
return _v; }
66 double x()
const {
return _v[0]; }
68 double y()
const {
return _v[1]; }
70 double z()
const {
return _v[2]; }
74 return _v[0] * v._v[0] + _v[1] * v._v[1] + _v[2] * v._v[2];
102 return Vector3d(_v[1] * v._v[2] - _v[2] * v._v[1],
103 _v[2] * v._v[0] - _v[0] * v._v[2],
104 _v[0] * v._v[1] - _v[1] * v._v[0]);
144 Vector3d & operator*=(
double s) { *
this = *
this * s;
return *
this; }
145 Vector3d & operator/=(
double s) { *
this = *
this / s;
return *
this; }
146 Vector3d & operator+=(
Vector3d const & v) { *
this = *
this + v;
return *
this; }
147 Vector3d & operator-=(
Vector3d const & v) { *
this = *
this - v;
return *
this; }
165 inline Vector3d operator*(
double s, Vector3d
const & v) {
return v * s; }
167 std::ostream & operator<<(std::ostream &, Vector3d
const &);
171 #endif // LSST_SPHGEOM_VECTOR3D_H_
Vector3d operator*(double s) const
Definition: Vector3d.h:116
Vector3d operator-() const
The unary minus operator negates every component of this vector.
Definition: Vector3d.h:108
double dot(Vector3d const &v) const
dot returns the inner product of this vector and v.
Definition: Vector3d.h:73
Vector3d(double x, double y, double z)
This constructor creates a vector with the given components.
Definition: Vector3d.h:50
bool isNormalized() const
isNormalized returns true if this vectors norm is very close to 1.
Definition: Vector3d.h:96
double getNorm() const
getNorm returns the L2 norm of this vector.
Definition: Vector3d.h:81
double normalize()
Definition: Vector3d.cc:41
Vector3d operator+(Vector3d const &v) const
The addition operator returns the sum of this vector and v.
Definition: Vector3d.h:131
Vector3d operator/(double s) const
Definition: Vector3d.h:124
Vector3d cwiseProduct(Vector3d const &v) const
cwiseProduct returns the component-wise product of this vector and v.
Definition: Vector3d.h:150
double operator()(int i) const
The function call operator returns the i-th component of this vector.
Definition: Vector3d.h:64
double getSquaredNorm() const
getSquaredNorm returns the inner product of this vector with itself.
Definition: Vector3d.h:78
Vector3d is a vector in ℝ³ with components stored in double precision.
Definition: Vector3d.h:44
bool isZero() const
isZero returns true if all the components of this vector are zero.
Definition: Vector3d.h:86
double const * getData() const
data returns a pointer to the 3 components of this vector.
Definition: Vector3d.h:61
Definition: UnitVector3d.h:55
Vector3d cross(Vector3d const &v) const
cross returns the cross product of this vector and v.
Definition: Vector3d.h:101
Vector3d()
The default constructor creates a zero vector.
Definition: Vector3d.h:47
Vector3d operator-(Vector3d const &v) const
The subtraction operator returns the difference between this vector and v.
Definition: Vector3d.h:138
Vector3d rotatedAround(UnitVector3d const &k, Angle a) const
Definition: Vector3d.cc:125