|
GeographicLib 2.6
|
An accurate representation of angles. More...
#include <GeographicLib/Angle.hpp>
Public Member Functions | |
Inspector functions. | |
| T | s () const |
| T | c () const |
| T | t () const |
| T | n () const |
| T | n0 () const |
Converting AngleT into other representations | |
| operator T () const | |
| T | degrees () const |
| T | degrees0 () const |
| T | radians () const |
| T | radians0 () const |
| T | lam () const |
| AngleT | nearest (unsigned ind=0U) const |
| T | ncardinal () const |
| unsigned | quadrant () const |
Elementary arithmetic operations on AngleT | |
| AngleT | operator- () const |
| AngleT & | operator+= (const AngleT &p) |
| AngleT & | operator-= (const AngleT &p) |
| AngleT | operator+ (const AngleT &p) const |
| AngleT | operator- (const AngleT &p) const |
| bool | zerop (T mult=0) const |
| bool | operator== (const AngleT &p) const |
Operations which modify a AngleT | |
| AngleT & | round () |
| AngleT & | renormalize () |
| AngleT & | setn (T n=0) |
| AngleT & | setn0 (T n=0) |
| AngleT & | setquadrant (unsigned q) |
| AngleT & | reflect (bool flips, bool flipc=false, bool swapp=false) |
Operations which return a new AngleT | |
| AngleT | base () const |
| AngleT | rebase (const AngleT &c) const |
| AngleT | flipsign (T mult) const |
| AngleT | modang (T m) const |
Static Public Member Functions | |
Converting AngleT to and from a string representation | |
| static void | DecodeLatLon (const std::string &stra, const std::string &strb, AngleT &lat, AngleT &lon, bool longfirst=false) |
| static AngleT | DecodeAzimuth (const std::string &azistr) |
| static std::string | LatLonString (AngleT lat, AngleT lon, int prec, bool dms=false, char dmssep='\0', bool longfirst=false) |
| static std::string | AzimuthString (AngleT azi, int prec, bool dms=false, char dmssep='\0') |
Creating AngleT objects. | |
| AngleT () | |
| AngleT (T s, T c, T num=0, bool normp=false) | |
| AngleT (T deg) | |
| static AngleT | degrees (T deg) |
| static AngleT | radians (T rad) |
| static AngleT | lam (T q) |
| static AngleT | NaN () |
| static AngleT | cardinal (T q) |
| static AngleT | eps () |
An accurate representation of angles.
| T | the working floating point type. |
This class provides an accurate representation of angle via 3 numbers, its sine = s and cosine = c, and the number of turns = n. The angle is then 2n π + atan2(s, c). This representation offers several advantages:
This representation does not favor degrees over radians. However, the one-argument constructor, AngleT(T), does the conversion from degrees and the cast to T, AngleT::operator T(), returns the angle in degrees. There are alternatives, radians(T) and radians() const, to allow these conversions with radians.
N.B. n is stored as a real. This allows it to be inf or nan.
Example of use:
|
inline |
The default constructor.
This sets the angle to 0.
Definition at line 65 of file Angle.hpp.
Referenced by AzimuthString(), base(), cardinal(), DecodeAzimuth(), DecodeLatLon(), degrees(), eps(), flipsign(), lam(), LatLonString(), modang(), NaN(), nearest(), operator T(), operator+(), operator+=(), operator-(), operator-(), operator-=(), operator==(), radians(), rebase(), reflect(), renormalize(), round(), setn(), setn0(), and setquadrant().
|
inline |
The general constructor.
| [in] | s | the sine component. |
| [in] | c | the cosine component. |
| [in] | num | the number of turns (default 0). |
| [in] | normp | are s and c normalized (default false). |
By default, the point (s, c) is scaled to lie on the unit circle. Setting normp = true skips this step; in this case (s, c) should already lie on the unit circle.
Definition at line 472 of file Angle.hpp.
References c(), GeographicLib::Math::NaN(), and s().
|
inlineexplicit |
The 1-argument constructor.
| [in] | deg | the angle in degrees. |
Definition at line 505 of file Angle.hpp.
References GeographicLib::Math::atan2d(), GeographicLib::Math::sincosd(), and GeographicLib::Math::td.
|
inlinestatic |
|
inlinestatic |
Convert an angle in radians to an AngleT.
| [in] | rad | the angle in radians. |
Definition at line 534 of file Angle.hpp.
References AngleT(), and GeographicLib::Math::pi().
Referenced by GeographicLib::Triaxial::Geodesic3::Inverse().
|
inlinestatic |
|
inlinestatic |
Not an angle.
Definition at line 567 of file Angle.hpp.
References AngleT(), and GeographicLib::Math::NaN().
Referenced by cardinal(), and modang().
|
inlinestatic |
|
inlinestatic |
|
inline |
Definition at line 149 of file Angle.hpp.
Referenced by AngleT(), GeographicLib::Triaxial::Ellipsoid3::AngNorm(), GeographicLib::Triaxial::Ellipsoid3::AngNorm(), cardinal(), GeographicLib::Triaxial::Ellipsoid3::cart2toellip(), GeographicLib::Triaxial::Ellipsoid3::elliptocart2(), GeographicLib::Triaxial::Ellipsoid3::elliptocart2(), GeographicLib::Triaxial::Conformal3::ForwardSphere(), GeographicLib::Triaxial::Geodesic3::Inverse(), nearest(), GeographicLib::Triaxial::GeodesicLine3::Position(), and GeographicLib::Triaxial::Conformal3::ReverseSphere().
|
inline |
Definition at line 153 of file Angle.hpp.
Referenced by AngleT(), GeographicLib::Triaxial::Ellipsoid3::AngNorm(), GeographicLib::Triaxial::Ellipsoid3::AngNorm(), cardinal(), GeographicLib::Triaxial::Ellipsoid3::cart2toellip(), GeographicLib::Triaxial::Ellipsoid3::elliptocart2(), GeographicLib::Triaxial::Ellipsoid3::elliptocart2(), GeographicLib::Triaxial::Geodesic3::Inverse(), main(), nearest(), operator+=(), GeographicLib::Triaxial::GeodesicLine3::Position(), rebase(), GeographicLib::Triaxial::Conformal3::ReverseSphere(), GeographicLib::Triaxial::Conformal3::x(), and GeographicLib::Triaxial::Conformal3::y().
|
inline |
Definition at line 157 of file Angle.hpp.
Referenced by lam(), operator+(), operator-(), operator==(), and rebase().
|
inline |
Definition at line 161 of file Angle.hpp.
Referenced by main(), setn(), setn0(), GeographicLib::Triaxial::Conformal3::x(), and GeographicLib::Triaxial::Conformal3::y().
|
inline |
|
inlineexplicit |
Convert an AngleT to degrees via a type conversion.
Definition at line 512 of file Angle.hpp.
References AngleT(), degrees0(), and GeographicLib::Math::td.
|
inline |
Convert an AngleT to degrees.
|
inline |
Convert an AngleT to degrees ignoring the number of turns.
Definition at line 529 of file Angle.hpp.
References GeographicLib::Math::atan2d().
Referenced by operator T().
|
inline |
Convert an AngleT to radians.
Definition at line 542 of file Angle.hpp.
References GeographicLib::Math::pi(), and radians0().
|
inline |
Convert an AngleT to radians ignoring the number of turns.
Definition at line 549 of file Angle.hpp.
Referenced by GeographicLib::Triaxial::Geodesic3::Inverse(), and radians().
|
inline |
|
inline |
Return the nearest cardinal direction as an AngleT.
| [in] | ind | an indicator. |
If ind == 0 (the default) the closest cardinal direction is returned. Otherwise, if ind is even, the closest even (N/S) cardinal direction is returned; or, if ind is odd, the closest odd (E/W) cardinal direction is returned.
|
inline |
Return the nearest cardinal direction as an integer.
Definition at line 572 of file Angle.hpp.
Referenced by operator+=().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
"Round" the AngleT the == operator.
This ensures that the smallest gaps between sine and cosine values is ε/2048.
Definition at line 636 of file Angle.hpp.
References AngleT().
Referenced by GeographicLib::Triaxial::GeodesicLine3::GeodesicLine3(), GeographicLib::Triaxial::Geodesic3::Inverse(), and GeographicLib::Triaxial::GeodesicLine3::Position().
|
inline |
|
inline |
Reduce the angle to [−180°, +180°]
Definition at line 662 of file Angle.hpp.
Referenced by GeographicLib::Triaxial::Geodesic3::Inverse(), GeographicLib::Triaxial::GeodesicLine3::pos1(), and GeographicLib::Triaxial::GeodesicLine3::Position().
|
inline |
|
inline |
Set the quadrant of an AngleT the angle to (−180°, +180°]
| [in] | q | the quadrant. |
This sets the signs of s() and c() according to e q.
Definition at line 682 of file Angle.hpp.
References AngleT().
Referenced by GeographicLib::Triaxial::Geodesic3::Inverse(), and GeographicLib::Triaxial::GeodesicLine3::fline::fics::setquadrant().
|
inline |
Reflect the angle is various ways
| [in] | flips | change the sign of s() |
| [in] | flipc | change the sign of c() |
| [in] | swapp | swap s() and c() |
Definition at line 696 of file Angle.hpp.
References AngleT(), and std::swap().
Referenced by BiaxialCoords(), GeographicLib::Triaxial::Geodesic3::Inverse(), GeographicLib::Triaxial::GeodesicLine3::fline::fics::pos1(), and GeographicLib::Triaxial::GeodesicLine3::Position().
|
inline |
|
inline |
Return an AngleT centered about another AngleT
| [in] | c | the center AngleT |
This returns the result of adjusting n() so that the new AngleT is with ±180° of c.
Definition at line 647 of file Angle.hpp.
References AngleT(), base(), c(), n0(), and t().
Referenced by GeographicLib::Triaxial::GeodesicLine3::Position().
|
inline |
Return an AngleT with the sign optionally flipped
| [in] | mult |
return signbit(mult) ? -*this : *this.
Definition at line 705 of file Angle.hpp.
References AngleT().
Referenced by GeographicLib::Triaxial::Geodesic3::Inverse(), and GeographicLib::Triaxial::GeodesicLine3::Position().
|
inline |
The "reduced latitude" operation.
| [in] | m |
However the quadrant of the result tracking that of *this through multiples turns.
Definition at line 711 of file Angle.hpp.
References AngleT(), and NaN().
Referenced by GeographicLib::Triaxial::Conformal3::beta(), BiaxialCoords(), GeographicLib::Triaxial::Cartesian3::meridianplane(), GeographicLib::Triaxial::Conformal3::omega(), GeographicLib::Triaxial::Conformal3::x(), and GeographicLib::Triaxial::Conformal3::y().
|
static |
Interpret two strings as latitude and longitude.
| [in] | stra | the first string |
| [in] | strb | the second string |
| [out] | lat | the latitude |
| [out] | lon | the longitude |
| [in] | longfirst | (defaultfirst) whether the longitude is given first. |
In the absence of hemisphere indicators (N/S for latitude and E/W for longitude), it is assumed that the first string is the latitude. Setting longfirst = true uses the opposite convention. The hemisphere indicators can also be used to set the signs of the angles.
Definition at line 39 of file Angle.cpp.
References AngleT(), GeographicLib::DMS::Decode(), GeographicLib::DMS::LATITUDE, GeographicLib::DMS::LONGITUDE, and GeographicLib::DMS::NONE.
|
static |
Interpret a string as azimuth
| [in] | azistr | the string representing the azimuth |
The hemisphere indicators E/W can be used to set the sign of the azimuth.
Definition at line 62 of file Angle.cpp.
References AngleT(), GeographicLib::DMS::Decode(), and GeographicLib::DMS::LATITUDE.
|
static |
Create a string for a latitude-longitude pair.
| [in] | lat | the latitude. |
| [in] | lon | the longitude. |
| [in] | prec | the precision relative to 1°. |
| [in] | dms | (default false) whether to use degrees/minutes/seconds as opposed to decimal degrees |
| [in] | dmssep | (default NULL) the separator to use with the DMS representation instead of d ' ". |
| [in] | longfirst | (default false) whether to list the longitude first. |
With dms = true the hemisphere indicators N/S and E/W are used to indicator the signs of the latitude and longitude.
Definition at line 72 of file Angle.cpp.
References AngleT(), GeographicLib::DMS::Encode(), GeographicLib::DMS::LATITUDE, GeographicLib::DMS::LONGITUDE, and GeographicLib::DMS::NUMBER.
|
static |
Create a string for an azimuth.
| [in] | azi | the azimuth. |
| [in] | prec | the precision relative to 1°. |
| [in] | dms | (default false) whether to use degrees/minutes/seconds as opposed to decimal degrees |
| [in] | dmssep | (default NULL) the separator to use with the DMS representation instead of d ' ". |
With dms = true the hemisphere indicators and E/W is used to indicator the sign of the azimuth.
Definition at line 86 of file Angle.cpp.
References AngleT(), GeographicLib::DMS::AZIMUTH, GeographicLib::DMS::Encode(), and GeographicLib::DMS::NUMBER.