siderust-cpp 0.8.0
Header-only C++ wrapper for siderust
Loading...
Searching...
No Matches
siderust::cartesian::Position< C, F, U > Struct Template Reference

A 3D Cartesian position, compile-time tagged by center, frame, unit. More...

#include <siderust/coordinates/cartesian.hpp>

Public Member Functions

 Position ()
 Position (U x_, U y_, U z_)
 Position (double x_, double y_, double z_)
U x () const
U y () const
U z () const
U distance () const
spherical::Position< C, F, U > to_spherical () const
 Convert this cartesian position to a spherical Position<C,F,U>.
U distance_to (const Position &other) const
siderust_cartesian_pos_t to_c () const
 Convert to C FFI struct.
template<typename Target>
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Position< C, Target, U > > to_frame (const Time< TT, JD > &jd) const
 Transform this position to a different reference frame (same center).
template<typename Target>
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Position< C, Target, U > > to_frame_with (const Time< TT, JD > &jd, const AstroContext &ctx) const
 Transform this position with an explicit astronomical context.
template<typename Target>
auto to (const Time< TT, JD > &jd) const -> decltype(this->template to_frame< Target >(jd))
 Shorthand: .to<Target>(jd) (calls to_frame).
template<typename TargetC>
std::enable_if_t< centers::has_center_transform_v< C, TargetC >, Position< TargetC, F, U > > to_center (const Time< TT, JD > &jd) const
 Transform this position to a different reference center (same frame).
template<typename TargetC, typename TargetF>
std::enable_if_t< frames::has_frame_transform_v< F, TargetF > &&centers::has_center_transform_v< C, TargetC >, Position< TargetC, TargetF, U > > transform (const Time< TT, JD > &jd) const
 Combined frame + center transform in one call.
Displacement< F, U > operator- (const Position &other) const
 Subtract two positions in the same center/frame/unit.
Position operator+ (const Displacement< F, U > &displacement) const
 Translate a position by a displacement.
Position operator- (const Displacement< F, U > &displacement) const
 Translate a position backwards by a displacement.
U magnitude () const
 Magnitude of the position vector (alias for distance()).
template<typename Target>
std::enable_if_t< siderust::frames::has_frame_transform_v< F, Target >, siderust::spherical::Position< C, Target, U > > to_frame (const Time< TT, JD > &jd) const
template<typename Target>
std::enable_if_t< siderust::frames::has_frame_transform_v< F, Target >, siderust::spherical::Position< C, Target, U > > to_frame_with (const Time< TT, JD > &jd, const AstroContext &ctx) const

Static Public Member Functions

static constexpr siderust_frame_t frame_id ()
static constexpr siderust_center_t center_id ()
static Position from_c (const siderust_cartesian_pos_t &c)
 Create from C FFI struct (ignoring runtime frame/center - trust the type).

Public Attributes

U comp_x
 X component.
U comp_y
 Y component.
U comp_z
 Z component.

Detailed Description

template<typename C, typename F, typename U>
struct siderust::cartesian::Position< C, F, U >

A 3D Cartesian position, compile-time tagged by center, frame, unit.

Mirrors Rust's affn::cartesian::Position<C, F, U>.

Template Parameters
CReference center tag (e.g. centers::Geocentric).
FReference frame tag (e.g. frames::ECEF).
ULength unit (default: qtty::Meter).
Examples
01_basic_coordinates.cpp, 02_coordinate_transformations.cpp, 03_all_frames_conversions.cpp, 04_all_center_conversions.cpp, and 11_serde_serialization.cpp.

Definition at line 286 of file cartesian.hpp.

Constructor & Destructor Documentation

◆ Position() [1/3]

◆ Position() [2/3]

template<typename C, typename F, typename U>
siderust::cartesian::Position< C, F, U >::Position ( U x_,
U y_,
U z_ )
inline

Definition at line 296 of file cartesian.hpp.

◆ Position() [3/3]

template<typename C, typename F, typename U>
siderust::cartesian::Position< C, F, U >::Position ( double x_,
double y_,
double z_ )
inline

Definition at line 298 of file cartesian.hpp.

Member Function Documentation

◆ center_id()

template<typename C, typename F, typename U>
constexpr siderust_center_t siderust::cartesian::Position< C, F, U >::center_id ( )
inlinestaticconstexpr

◆ distance()

template<typename C, typename F, typename U>
U siderust::cartesian::Position< C, F, U >::distance ( ) const
inline

◆ distance_to()

template<typename C, typename F, typename U>
U siderust::cartesian::Position< C, F, U >::distance_to ( const Position< C, F, U > & other) const
inline

Definition at line 317 of file cartesian.hpp.

◆ frame_id()

template<typename C, typename F, typename U>
constexpr siderust_frame_t siderust::cartesian::Position< C, F, U >::frame_id ( )
inlinestaticconstexpr

◆ from_c()

template<typename C, typename F, typename U>
Position siderust::cartesian::Position< C, F, U >::from_c ( const siderust_cartesian_pos_t & c)
inlinestatic

Create from C FFI struct (ignoring runtime frame/center - trust the type).

Definition at line 334 of file cartesian.hpp.

◆ magnitude()

template<typename C, typename F, typename U>
U siderust::cartesian::Position< C, F, U >::magnitude ( ) const
inline

Magnitude of the position vector (alias for distance()).

Definition at line 477 of file cartesian.hpp.

◆ operator+()

template<typename C, typename F, typename U>
Position siderust::cartesian::Position< C, F, U >::operator+ ( const Displacement< F, U > & displacement) const
inline

Translate a position by a displacement.

Returns a new Position offset by the displacement vector.

Definition at line 459 of file cartesian.hpp.

◆ operator-() [1/2]

template<typename C, typename F, typename U>
Position siderust::cartesian::Position< C, F, U >::operator- ( const Displacement< F, U > & displacement) const
inline

Translate a position backwards by a displacement.

Returns a new Position offset by the negated displacement vector.

Definition at line 469 of file cartesian.hpp.

◆ operator-() [2/2]

template<typename C, typename F, typename U>
Displacement< F, U > siderust::cartesian::Position< C, F, U >::operator- ( const Position< C, F, U > & other) const
inline

Subtract two positions in the same center/frame/unit.

Returns a Displacement representing the vector from other to this. This is the only valid Position-Position operation in affine geometry.

Definition at line 448 of file cartesian.hpp.

◆ to()

template<typename C, typename F, typename U>
template<typename Target>
auto siderust::cartesian::Position< C, F, U >::to ( const Time< TT, JD > & jd) const->decltype(this->templateto_frame< Target >(jd))
inline

Shorthand: .to<Target>(jd) (calls to_frame).

Definition at line 383 of file cartesian.hpp.

◆ to_c()

◆ to_center()

template<typename C, typename F, typename U>
template<typename TargetC>
std::enable_if_t< centers::has_center_transform_v< C, TargetC >, Position< TargetC, F, U > > siderust::cartesian::Position< C, F, U >::to_center ( const Time< TT, JD > & jd) const
inline

Transform this position to a different reference center (same frame).

The FFI center-shift uses VSOP87 ephemeris vectors expressed in EclipticMeanJ2000. When the position is already in that frame the FFI call is made directly; otherwise the position is first rotated to ecliptic, shifted, and rotated back so the result is frame-correct.

Template Parameters
TargetCDestination center tag.
Parameters
jdJulian Date (TT) for the ephemeris evaluation.

Definition at line 401 of file cartesian.hpp.

Referenced by siderust::cartesian::Position< centers::Heliocentric, frames::EclipticMeanJ2000, U >::to_center(), and siderust::cartesian::Position< centers::Heliocentric, frames::EclipticMeanJ2000, U >::transform().

◆ to_frame() [1/2]

template<typename C, typename F, typename U>
template<typename Target>
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Position< C, Target, U > > siderust::cartesian::Position< C, F, U >::to_frame ( const Time< TT, JD > & jd) const
inline

Transform this position to a different reference frame (same center).

Only a pure rotation is applied; the reference center is unchanged. Only enabled when a FrameRotationProvider exists for the pair (F, Target).

Template Parameters
TargetDestination frame tag.
Parameters
jdJulian Date (TT) for time-dependent rotations.
Examples
02_coordinate_transformations.cpp.

Definition at line 349 of file cartesian.hpp.

Referenced by siderust::cartesian::Position< centers::Heliocentric, frames::EclipticMeanJ2000, U >::to(), siderust::cartesian::Position< centers::Heliocentric, frames::EclipticMeanJ2000, U >::to_center(), and siderust::cartesian::Position< centers::Heliocentric, frames::EclipticMeanJ2000, U >::transform().

◆ to_frame() [2/2]

template<typename C, typename F, typename U>
template<typename Target>
std::enable_if_t< siderust::frames::has_frame_transform_v< F, Target >, siderust::spherical::Position< C, Target, U > > siderust::cartesian::Position< C, F, U >::to_frame ( const Time< TT, JD > & jd) const

Definition at line 62 of file pos_conversions.hpp.

◆ to_frame_with() [1/2]

template<typename C, typename F, typename U>
template<typename Target>
std::enable_if_t< frames::has_frame_transform_v< F, Target >, Position< C, Target, U > > siderust::cartesian::Position< C, F, U >::to_frame_with ( const Time< TT, JD > & jd,
const AstroContext & ctx ) const
inline

Transform this position with an explicit astronomical context.

Definition at line 366 of file cartesian.hpp.

◆ to_frame_with() [2/2]

template<typename C, typename F, typename U>
template<typename Target>
std::enable_if_t< siderust::frames::has_frame_transform_v< F, Target >, siderust::spherical::Position< C, Target, U > > siderust::cartesian::Position< C, F, U >::to_frame_with ( const Time< TT, JD > & jd,
const AstroContext & ctx ) const

Definition at line 74 of file pos_conversions.hpp.

◆ to_spherical()

template<typename C, typename F, typename U>
spherical::Position< C, F, U > siderust::cartesian::Position< C, F, U >::to_spherical ( ) const

Convert this cartesian position to a spherical Position<C,F,U>.

Examples
01_basic_coordinates.cpp.

Definition at line 17 of file pos_conversions.hpp.

References comp_x, comp_y, comp_z, siderust::constants::pi, x(), y(), and z().

◆ transform()

template<typename C, typename F, typename U>
template<typename TargetC, typename TargetF>
std::enable_if_t< frames::has_frame_transform_v< F, TargetF > &&centers::has_center_transform_v< C, TargetC >, Position< TargetC, TargetF, U > > siderust::cartesian::Position< C, F, U >::transform ( const Time< TT, JD > & jd) const
inline

Combined frame + center transform in one call.

Routes through EclipticMeanJ2000 for the center shift so that VSOP87 ephemeris vectors are applied in the correct frame:

  1. rotate to EclipticMeanJ2000
  2. shift center
  3. rotate to target frame
Template Parameters
TargetCDestination center tag.
TargetFDestination frame tag.
Parameters
jdJulian Date (TT).

Definition at line 436 of file cartesian.hpp.

◆ x()

template<typename C, typename F, typename U>
U siderust::cartesian::Position< C, F, U >::x ( ) const
inline

Definition at line 300 of file cartesian.hpp.

Referenced by siderust::cartesian::operator<<(), and to_spherical().

◆ y()

template<typename C, typename F, typename U>
U siderust::cartesian::Position< C, F, U >::y ( ) const
inline

Definition at line 301 of file cartesian.hpp.

Referenced by siderust::cartesian::operator<<(), and to_spherical().

◆ z()

template<typename C, typename F, typename U>
U siderust::cartesian::Position< C, F, U >::z ( ) const
inline

Definition at line 302 of file cartesian.hpp.

Referenced by siderust::cartesian::operator<<(), and to_spherical().

Member Data Documentation

◆ comp_x

◆ comp_y

◆ comp_z


The documentation for this struct was generated from the following files: