LSST Applications
21.0.0-172-gfb10e10a+18fedfabac,22.0.0+297cba6710,22.0.0+80564b0ff1,22.0.0+8d77f4f51a,22.0.0+a28f4c53b1,22.0.0+dcf3732eb2,22.0.1-1-g7d6de66+2a20fdde0d,22.0.1-1-g8e32f31+297cba6710,22.0.1-1-geca5380+7fa3b7d9b6,22.0.1-12-g44dc1dc+2a20fdde0d,22.0.1-15-g6a90155+515f58c32b,22.0.1-16-g9282f48+790f5f2caa,22.0.1-2-g92698f7+dcf3732eb2,22.0.1-2-ga9b0f51+7fa3b7d9b6,22.0.1-2-gd1925c9+bf4f0e694f,22.0.1-24-g1ad7a390+a9625a72a8,22.0.1-25-g5bf6245+3ad8ecd50b,22.0.1-25-gb120d7b+8b5510f75f,22.0.1-27-g97737f7+2a20fdde0d,22.0.1-32-gf62ce7b1+aa4237961e,22.0.1-4-g0b3f228+2a20fdde0d,22.0.1-4-g243d05b+871c1b8305,22.0.1-4-g3a563be+32dcf1063f,22.0.1-4-g44f2e3d+9e4ab0f4fa,22.0.1-42-gca6935d93+ba5e5ca3eb,22.0.1-5-g15c806e+85460ae5f3,22.0.1-5-g58711c4+611d128589,22.0.1-5-g75bb458+99c117b92f,22.0.1-6-g1c63a23+7fa3b7d9b6,22.0.1-6-g50866e6+84ff5a128b,22.0.1-6-g8d3140d+720564cf76,22.0.1-6-gd805d02+cc5644f571,22.0.1-8-ge5750ce+85460ae5f3,master-g6e05de7fdc+babf819c66,master-g99da0e417a+8d77f4f51a,w.2021.48
LSST Data Management Base Package
|
UnitVector3d
is a unit vector in ℝ³ with components stored in double precision.
More...
#include <UnitVector3d.h>
Public Member Functions | |
UnitVector3d () | |
The default constructor creates a unit vector equal to (1, 0, 0). More... | |
UnitVector3d (UnitVector3d const &v)=default | |
UnitVector3d (LonLat const &p) | |
This constructor creates the unit vector corresponding to the point p on the unit sphere. More... | |
UnitVector3d (Angle lon, Angle lat) | |
This constructor creates a unit vector corresponding to the given spherical coordinates. More... | |
operator Vector3d const & () const | |
This conversion operator returns a const reference to the underlying Vector3d. More... | |
bool | operator== (Vector3d const &v) const |
bool | operator!= (Vector3d const &v) const |
double const * | getData () const |
getData returns a pointer to the 3 components of this unit vector. More... | |
double | operator() (int i) const |
The function call operator returns the i -th component of this vector. More... | |
double | x () const |
double | y () const |
double | z () const |
double | dot (Vector3d const &v) const |
dot returns the inner product of this unit vector and v . More... | |
Vector3d | cross (Vector3d const &v) const |
cross returns the cross product of this unit vector and v . More... | |
Vector3d | robustCross (UnitVector3d const &v) const |
a.robustCross(b) is (b + a).cross(b - a) - twice the cross product of a and b. More... | |
UnitVector3d | operator- () const |
The unary minus operator negates every component of this unit vector. More... | |
Vector3d | operator* (double s) const |
The multiplication operator returns the component-wise product of this unit vector with scalar s . More... | |
Vector3d | operator/ (double s) const |
The division operator returns the component-wise quotient of this unit vector with scalar s . More... | |
Vector3d | operator+ (Vector3d const &v) const |
The addition operator returns the sum of this unit vector and v . More... | |
Vector3d | operator- (Vector3d const &v) const |
The subtraction operator returns the difference between this unit vector and v . More... | |
Vector3d | cwiseProduct (Vector3d const &v) const |
cwiseProduct returns the component-wise product of this unit vector and v . More... | |
UnitVector3d | rotatedAround (UnitVector3d const &k, Angle a) const |
rotatedAround returns a copy of this unit vector, rotated around the unit vector k by angle a according to the right hand rule. More... | |
UnitVector3d (Vector3d const &v) | |
UnitVector3d (double x, double y, double z) | |
Static Public Member Functions | |
static UnitVector3d | orthogonalTo (Vector3d const &v) |
orthogonalTo returns an arbitrary unit vector that is orthogonal to v. More... | |
static UnitVector3d | orthogonalTo (Vector3d const &v1, Vector3d const &v2) |
orthogonalTo returns the unit vector n orthogonal to both v1 and v2 and with the same direction as the cross product of v1 and v2. More... | |
static UnitVector3d | northFrom (Vector3d const &v) |
northFrom returns the unit vector orthogonal to v that points "north" from v. More... | |
static UnitVector3d | orthogonalTo (NormalizedAngle const &a) |
orthogonalTo returns the unit vector orthogonal to the meridian with the given longitude. More... | |
static UnitVector3d | fromNormalized (Vector3d const &v) |
fromNormalized returns the unit vector equal to v, which is assumed to be normalized. More... | |
static UnitVector3d | fromNormalized (double x, double y, double z) |
fromNormalized returns the unit vector with the given components, which are assumed to correspond to those of a normalized vector. More... | |
static UnitVector3d | X () |
static UnitVector3d | Y () |
static UnitVector3d | Z () |
UnitVector3d
is a unit vector in ℝ³ with components stored in double precision.
Conceptually, a UnitVector3d is a Vector3d. However, it does not inherit from Vector3d because all its mutators must correspond to isometries. Propagating this restriction to the Vector3d base class would make the base class unduly difficult to use. Furthermore, the base class assignment operator would have to be made virtual - otherwise it would be possible to cast a UnitVector3d reference to a Vector3d reference and then assign components yielding non-unit norm. For a class this compact and performance critical, the addition of a vtable pointer per instance and the potential for virtual call overhead on assignment is deemed prohibitive.
This class supports conversion from longitude and latitude angles. All methods that accept a LonLat
or equivalent angles shall convert from longitude/latitude to a unit vector according to the following conventions:
Definition at line 55 of file UnitVector3d.h.
|
inline |
The default constructor creates a unit vector equal to (1, 0, 0).
Definition at line 106 of file UnitVector3d.h.
|
default |
|
inlineexplicit |
This constructor creates a unit vector with the given direction.
Definition at line 112 of file UnitVector3d.h.
|
inline |
This constructor creates a unit vector with the given direction.
Definition at line 116 of file UnitVector3d.h.
|
inlineexplicit |
This constructor creates the unit vector corresponding to the point p
on the unit sphere.
Definition at line 123 of file UnitVector3d.h.
This constructor creates a unit vector corresponding to the given spherical coordinates.
Definition at line 63 of file UnitVector3d.cc.
cross
returns the cross product of this unit vector and v
.
Definition at line 155 of file UnitVector3d.h.
cwiseProduct
returns the component-wise product of this unit vector and v
.
Definition at line 187 of file UnitVector3d.h.
|
inline |
dot
returns the inner product of this unit vector and v
.
Definition at line 152 of file UnitVector3d.h.
|
inlinestatic |
fromNormalized
returns the unit vector with the given components, which are assumed to correspond to those of a normalized vector.
Use with caution - this assumption is not verified!
Definition at line 89 of file UnitVector3d.h.
|
inlinestatic |
fromNormalized
returns the unit vector equal to v, which is assumed to be normalized.
Use with caution - this assumption is not verified!
Definition at line 82 of file UnitVector3d.h.
|
inline |
getData
returns a pointer to the 3 components of this unit vector.
Definition at line 140 of file UnitVector3d.h.
|
static |
northFrom
returns the unit vector orthogonal to v that points "north" from v.
More precisely, it returns a unit vector orthogonal to v that lies in the plane defined by v, the north pole (0, 0, 1), and the origin. If v is colinear with the z axis, then (-1, 0, 0) is returned if v points north, and (1, 0, 0) is returned if v points south.
Definition at line 51 of file UnitVector3d.cc.
|
inline |
This conversion operator returns a const reference to the underlying Vector3d.
It allows a UnitVector3d to transparently replace a Vector3d as an argument in most function calls.
Definition at line 134 of file UnitVector3d.h.
|
inline |
Definition at line 137 of file UnitVector3d.h.
|
inline |
The function call operator returns the i
-th component of this vector.
Definition at line 143 of file UnitVector3d.h.
|
inline |
The multiplication operator returns the component-wise product of this unit vector with scalar s
.
Definition at line 172 of file UnitVector3d.h.
The addition operator returns the sum of this unit vector and v
.
Definition at line 179 of file UnitVector3d.h.
|
inline |
The unary minus operator negates every component of this unit vector.
Definition at line 166 of file UnitVector3d.h.
The subtraction operator returns the difference between this unit vector and v
.
Definition at line 183 of file UnitVector3d.h.
|
inline |
The division operator returns the component-wise quotient of this unit vector with scalar s
.
Definition at line 176 of file UnitVector3d.h.
|
inline |
Definition at line 136 of file UnitVector3d.h.
|
inlinestatic |
orthogonalTo
returns the unit vector orthogonal to the meridian with the given longitude.
Definition at line 76 of file UnitVector3d.h.
|
static |
orthogonalTo
returns an arbitrary unit vector that is orthogonal to v.
Definition at line 34 of file UnitVector3d.cc.
|
static |
orthogonalTo
returns the unit vector n orthogonal to both v1 and v2 and with the same direction as the cross product of v1 and v2.
If v1 and v2 are nearly (anti)parallel, then an arbitrary unit vector orthogonal to v1 is returned.
Definition at line 41 of file UnitVector3d.cc.
|
inline |
a.robustCross(b)
is (b + a).cross(b - a)
- twice the cross product of a and b.
The result is almost orthogonal to a and b even for nearly (anti-)parallel unit vectors. The idea comes from the Google S2 library.
Definition at line 161 of file UnitVector3d.h.
|
inline |
rotatedAround
returns a copy of this unit vector, rotated around the unit vector k
by angle a
according to the right hand rule.
Definition at line 193 of file UnitVector3d.h.
|
inlinestatic |
Definition at line 93 of file UnitVector3d.h.
|
inline |
Definition at line 145 of file UnitVector3d.h.
|
inlinestatic |
Definition at line 97 of file UnitVector3d.h.
|
inline |
Definition at line 147 of file UnitVector3d.h.
|
inlinestatic |
Definition at line 101 of file UnitVector3d.h.
|
inline |
Definition at line 149 of file UnitVector3d.h.