lsst.afw  13.0-102-g6486c126f
Public Member Functions | Related Functions | List of all members
lsst::afw::geom::SpherePoint Class Referencefinal

Point in an unspecified spherical coordinate system. More...

#include <SpherePoint.h>

Public Member Functions

 SpherePoint (Angle const &longitude, Angle const &latitude)
 Construct a SpherePoint from a longitude and latitude. More...
 
 SpherePoint (double const lonLatRad[2])
 Construct a SpherePoint from a two-element array of radians. More...
 
 SpherePoint (Point3D const &vector)
 Construct a SpherePoint from a vector representing a direction. More...
 
 SpherePoint (SpherePoint const &other) noexcept
 Create a copy of a SpherePoint. More...
 
 SpherePoint (SpherePoint &&other) noexcept
 Create a copy of a SpherePoint. More...
 
SpherePoint & operator= (SpherePoint const &other) noexcept
 Overwrite this object with the value of another SpherePoint. More...
 
SpherePoint & operator= (SpherePoint &&other) noexcept
 Overwrite this object with the value of another SpherePoint. More...
 
Angle getLongitude () const noexcept
 The longitude of this point. More...
 
Angle getLatitude () const noexcept
 The latitude of this point. More...
 
Point3D getVector () const noexcept
 A unit vector representation of this point. More...
 
Angle operator[] (size_t index) const
 Longitude and latitude by index. More...
 
bool atPole () const noexcept
 true if this point is either coordinate pole. More...
 
bool isFinite () const noexcept
 true if this point is a well-defined position. More...
 
bool operator== (SpherePoint const &other) const noexcept
 true if two points represent the same position. More...
 
bool operator!= (SpherePoint const &other) const noexcept
 false if two points represent the same position. More...
 
Angle bearingTo (SpherePoint const &other) const
 Direction from one point to another. More...
 
Angle separation (SpherePoint const &other) const noexcept
 Angular distance between two points. More...
 
SpherePoint rotated (SpherePoint const &axis, Angle const &amount) const noexcept
 Return a point rotated from this one around an axis. More...
 
SpherePoint offset (Angle const &bearing, Angle const &amount) const
 Return a point offset from this one along a great circle. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, SpherePoint const &point)
 Print the value of a point to a stream. More...
 

Detailed Description

Point in an unspecified spherical coordinate system.

This class represents a point on a sphere in the mathematical rather than the astronomical sense. It does not refer to any astronomical reference frame, nor does it have any concept of (radial) distance.

Points can be represented either as spherical coordinates or as a unit vector. The adopted convention for converting between these two systems is that (0, 0) corresponds to <1, 0, 0>, that (π/2, 0) corresponds to <0, 1, 0>, and that (0, π/2) corresponds to <0, 0, 1>.

To keep usage simple, SpherePoint does not support modification of existing values; transformations of SpherePoints should be expressed as a new object. To support cases where a SpherePoint must be updated in-place, SpherePoint supports assignment to an existing object. One example is in containers of SpherePoints; no STL container has an atomic element-replacement method, so complicated constructions would need to be used if you couldn't overwrite an existing element.

See also
coord::Coord

Definition at line 60 of file SpherePoint.h.

Constructor & Destructor Documentation

◆ SpherePoint() [1/5]

lsst::afw::geom::SpherePoint::SpherePoint ( Angle const &  longitude,
Angle const &  latitude 
)

Construct a SpherePoint from a longitude and latitude.

Parameters
longitudeThe longitude of the point.
latitudeThe latitude of the point. Must be in the interval [-π/2, π/2] radians.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if latitude isout of range.
Exception Safety
Provides strong exception guarantee.

◆ SpherePoint() [2/5]

lsst::afw::geom::SpherePoint::SpherePoint ( double const  lonLatRad[2])
explicit

Construct a SpherePoint from a two-element array of radians.

Parameters
lonLatRadLongitude, latitude, both in radians.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if latitude is out of range.
Exception Safety
Provides strong exception guarantee.

◆ SpherePoint() [3/5]

lsst::afw::geom::SpherePoint::SpherePoint ( Point3D const &  vector)
explicit

Construct a SpherePoint from a vector representing a direction.

Parameters
vectorA position whose direction will be stored as a SpherePoint. Must not be the zero vector. Need not be normalized, and the norm will not affect the value of the point.
Exceptions
pex::exceptions::InvalidParameterErrorThrown if vector is the zero vector.
Exception Safety
Provides strong exception guarantee.

◆ SpherePoint() [4/5]

lsst::afw::geom::SpherePoint::SpherePoint ( SpherePoint const &  other)
noexcept

Create a copy of a SpherePoint.

Parameters
otherThe point to copy.
Exception Safety
Shall not throw exceptions.

◆ SpherePoint() [5/5]

lsst::afw::geom::SpherePoint::SpherePoint ( SpherePoint &&  other)
noexcept

Create a copy of a SpherePoint.

As SpherePoint(SpherePoint const&), except that other may be left in an unspecified but valid state.

Member Function Documentation

◆ atPole()

bool lsst::afw::geom::SpherePoint::atPole ( ) const
inlinenoexcept

true if this point is either coordinate pole.

Returns
true if this point is at the north or south pole, false otherwise
Exception Safety
Shall not throw exceptions.

Definition at line 201 of file SpherePoint.h.

◆ bearingTo()

Angle lsst::afw::geom::SpherePoint::bearingTo ( SpherePoint const &  other) const

Direction from one point to another.

This method finds the shortest (great-circle) arc between two points, and characterizes its direction by the angle between it and a line of latitude passing through this point. 0 represents due east, π/2 represents due north. If the points are on opposite sides of the sphere, the bearing may be any value.

Parameters
otherthe point to which to measure the bearing
Returns
the direction, as defined above, in the interval [0, 2π).
Exceptions
pex::exceptions::DomainErrorThrown if this.atPole().
Exception Safety
Provides strong exception guarantee.
Note
For two points A and B, A.bearingTo(B) will in general not be 180 degrees away from B.bearingTo(A).

◆ getLatitude()

Angle lsst::afw::geom::SpherePoint::getLatitude ( ) const
inlinenoexcept

The latitude of this point.

Returns
the latitude, in the interval [-π/2, π/2] radians.
Exception Safety
Shall not throw exceptions.

Definition at line 166 of file SpherePoint.h.

◆ getLongitude()

Angle lsst::afw::geom::SpherePoint::getLongitude ( ) const
inlinenoexcept

The longitude of this point.

If this point is at a coordinate pole, the longitude is undefined, and this method may return any value. If the SpherePoint implementation allows multiple values of longitude from a pole, they shall all be treated as valid representations of the same point.

Returns
the longitude, in the interval [0, 2π) radians.
Exception Safety
Shall not throw exceptions.

Definition at line 157 of file SpherePoint.h.

◆ getVector()

Point3D lsst::afw::geom::SpherePoint::getVector ( ) const
noexcept

A unit vector representation of this point.

Returns
a unit vector whose direction corresponds to this point
Exception Safety
Shall not throw exceptions.

◆ isFinite()

bool lsst::afw::geom::SpherePoint::isFinite ( ) const
noexcept

true if this point is a well-defined position.

Returns
true if getLongitude(), getLatitude(), and getVector() return finite floating-point values; false if any return NaN or infinity.
Exception Safety
Shall not throw exceptions.

◆ offset()

SpherePoint lsst::afw::geom::SpherePoint::offset ( Angle const &  bearing,
Angle const &  amount 
) const

Return a point offset from this one along a great circle.

For any point A not at a coordinate pole, and any two angles b and delta, A.bearingTo(A.offset(b, delta)) = b and A.separationTo(A.offset(b, delta)) = delta.

Parameters
bearingthe direction in which to move this point, following the conventions described in bearingTo.
amountthe distance by which to move along the great circle defined by bearing
Returns
a new point created by shifting this point
Exceptions
pex::exceptions::DomainErrorThrown if this.atPole().
pex::exceptions::InvalidParameterErrorThrown if amount is negative.
Exception Safety
Provides strong exception guarantee.

◆ operator!=()

bool lsst::afw::geom::SpherePoint::operator!= ( SpherePoint const &  other) const
noexcept

false if two points represent the same position.

This operator shall always return the logical negation of operator==(); see its documentation for a detailed specification.

◆ operator=() [1/2]

SpherePoint& lsst::afw::geom::SpherePoint::operator= ( SpherePoint const &  other)
noexcept

Overwrite this object with the value of another SpherePoint.

This is the only method that can alter the state of a SpherePoint after its construction, and is provided to allow in-place replacement of SpherePoints where swapping is not possible.

Parameters
otherThe object with which to overwrite this one.
Returns
a reference to this object.
Exception Safety
Shall not throw exceptions.

◆ operator=() [2/2]

SpherePoint& lsst::afw::geom::SpherePoint::operator= ( SpherePoint &&  other)
noexcept

Overwrite this object with the value of another SpherePoint.

As operator=(SpherePoint const&), except that other may be left in an unspecified but valid state.

◆ operator==()

bool lsst::afw::geom::SpherePoint::operator== ( SpherePoint const &  other) const
noexcept

true if two points represent the same position.

Points are considered equal if and only if they represent the same location, regardless of how they were constructed. In particular, representations of the north or south pole with different longitudes are considered equal.

Parameters
otherthe point to test for equality
Returns
true if this point matches other exactly, false otherwise
Exception Safety
Shall not throw exceptions.
Warning
Points whose getLongitude(), getLatitude(), or getVector() methods return NaN shall not compare equal to any point, including themselves. This may break algorithms that assume object equality is reflexive; use isFinite() to filter objects if necessary.

◆ operator[]()

Angle lsst::afw::geom::SpherePoint::operator[] ( size_t  index) const

Longitude and latitude by index.

Parameters
indexthe index of the spherical coordinate to return. Must be either 0 or 1.
Returns
getLongitude() if index = 0, or getLatitude() if index = 1
Exceptions
pex::exceptions::OutOfRangeErrorThrown if index is neither 0 nor 1.
Exception Safety
Provides strong exception guarantee.

◆ rotated()

SpherePoint lsst::afw::geom::SpherePoint::rotated ( SpherePoint const &  axis,
Angle const &  amount 
) const
noexcept

Return a point rotated from this one around an axis.

Parameters
axisa point defining the north pole of the rotation axis.
amountthe amount of rotation, where positive values represent right-handed rotations around axis.
Returns
a new point created by rotating this point
Exception Safety
Shall not throw exceptions.

◆ separation()

Angle lsst::afw::geom::SpherePoint::separation ( SpherePoint const &  other) const
noexcept

Angular distance between two points.

Parameters
otherthe point to which to measure the separation
Returns
the length of the shortest (great circle) arc between the two points. Shall not be negative.
Exception Safety
Shall not throw exceptions.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
SpherePoint const &  point 
)
related

Print the value of a point to a stream.

The exact details of the string representation are unspecified and subject to change, but the following may be regarded as typical: "(10.543250, +32.830583)".

Parameters
osthe stream to which to print point
pointthe point to print to the stream
Returns
a reference to os
Exceptions
pex::exceptions::std::ostream::failureThrown if an I/O state flag was set that was registered with os.exceptions(). See the documentation of std::ostream for more details.
Exception Safety
Provides basic exception guarantee.

The documentation for this class was generated from the following file: