30#ifndef LSST_SPHGEOM_VECTOR3D_H_
31#define LSST_SPHGEOM_VECTOR3D_H_
54 Vector3d() { _v[0] = 0.0; _v[1] = 0.0; _v[2] = 0.0; }
57 Vector3d(
double x,
double y,
double z) { _v[0] = x; _v[1] = y; _v[2] = z; }
59 bool operator==(
Vector3d const & v)
const {
60 return _v[0] == v._v[0] && _v[1] == v._v[1] && _v[2] == v._v[2];
63 bool operator!=(
Vector3d const & v)
const {
64 return _v[0] != v._v[0] || _v[1] != v._v[1] || _v[2] != v._v[2];
68 double const *
getData()
const {
return _v; }
73 double x()
const {
return _v[0]; }
75 double y()
const {
return _v[1]; }
77 double z()
const {
return _v[2]; }
81 return _v[0] * v._v[0] + _v[1] * v._v[1] + _v[2] * v._v[2];
109 return Vector3d(_v[1] * v._v[2] - _v[2] * v._v[1],
110 _v[2] * v._v[0] - _v[0] * v._v[2],
111 _v[0] * v._v[1] - _v[1] * v._v[0]);
151 Vector3d & operator*=(
double s) { *
this = *
this * s;
return *
this; }
152 Vector3d & operator/=(
double s) { *
this = *
this / s;
return *
this; }
153 Vector3d & operator+=(
Vector3d const & v) { *
this = *
this + v;
return *
this; }
154 Vector3d & operator-=(
Vector3d const & v) { *
this = *
this - v;
return *
this; }
172inline Vector3d operator*(
double s, Vector3d
const & v) {
return v * s; }
174std::ostream & operator<<(std::ostream &, Vector3d
const &);
Definition UnitVector3d.h:62
Vector3d is a vector in ℝ³ with components stored in double precision.
Definition Vector3d.h:51
Vector3d(double x, double y, double z)
This constructor creates a vector with the given components.
Definition Vector3d.h:57
Vector3d operator*(double s) const
Definition Vector3d.h:123
Vector3d cwiseProduct(Vector3d const &v) const
cwiseProduct returns the component-wise product of this vector and v.
Definition Vector3d.h:157
Vector3d rotatedAround(UnitVector3d const &k, Angle a) const
Definition Vector3d.cc:132
double dot(Vector3d const &v) const
dot returns the inner product of this vector and v.
Definition Vector3d.h:80
bool isNormalized() const
isNormalized returns true if this vectors norm is very close to 1.
Definition Vector3d.h:103
double const * getData() const
data returns a pointer to the 3 components of this vector.
Definition Vector3d.h:68
Vector3d operator-() const
The unary minus operator negates every component of this vector.
Definition Vector3d.h:115
Vector3d()
The default constructor creates a zero vector.
Definition Vector3d.h:54
double operator()(int i) const
The function call operator returns the i-th component of this vector.
Definition Vector3d.h:71
bool isZero() const
isZero returns true if all the components of this vector are zero.
Definition Vector3d.h:93
double getNorm() const
getNorm returns the L2 norm of this vector.
Definition Vector3d.h:88
Vector3d operator-(Vector3d const &v) const
The subtraction operator returns the difference between this vector and v.
Definition Vector3d.h:145
Vector3d operator/(double s) const
Definition Vector3d.h:131
double normalize()
Definition Vector3d.cc:48
Vector3d operator+(Vector3d const &v) const
The addition operator returns the sum of this vector and v.
Definition Vector3d.h:138
double getSquaredNorm() const
getSquaredNorm returns the inner product of this vector with itself.
Definition Vector3d.h:85
Vector3d cross(Vector3d const &v) const
cross returns the cross product of this vector and v.
Definition Vector3d.h:108