coord_value

namespace nin {
    template <coordsys_traits CT>
    class coord_value;
}

A coord_value wraps a coordinate quantity together with the coordinate system it is expressed in. This pairing prevents a common class of errors: accidentally mixing coordinates from different coordinate systems without an explicit transformation.

Equality comparison is deliberately deleted — comparing the raw numbers of two coord_value objects is meaningless unless they are in the same coordinate system, and the library does not silently transform behind your back.

Constructors (6) and (7) are the converting constructors: they accept a target coordinate system and an existing coord_value, internally calling mapCS() to transform the quantity into the new system.

Nested types

Type Definition

coordsys_traits

CT

quantity_type

CT::quantity_type

Member functions

(Constructor)

constructs a coordinate value

coord_value()

(1)

coord_value(coord_value const& copy)

(2)

coord_value(coord_value && move)

(3)

coord_value(coordsys<CT> cs, quantity_type qty = {})

(4)

coord_value(WCS_t, quantity_type qty = {})

(5)

coord_value(coordsys<CT> cs, coord_value value)

(6)

coord_value(WCS_t, coord_value value)

(7)

  • (1) Default constructor. In WCS with a default-constructed quantity.

  • (2)-(3) Copy and move.

  • (4)-(5) Constructs in a given coordinate system (or WCS) with an optional quantity.

  • (6)-(7) Transforms an existing coord_value into a different coordinate system. Internally equivalent to mapCS(value.inCS(), cs)(value).

Constructing from a bare quantity without a coordinate system is deleted — the coordinate system is always required.

inCS

associated coordinate system

coordsys<CT> const& inCS() const

(1)

Returns the coordinate system this value is expressed in.

qty

access the raw quantity

quantity_type const& qty() const

(1)

quantity_type & qty()

(2)

  • (1) Returns a const reference to the underlying coordinate quantity.

  • (2) Returns a mutable reference, allowing direct modification.

map_to

transform to another coordinate system

auto map_to(bridges_and_target…​) const

(1)

Returns a new coord_value in the target coordinate system. Accepts a coordsys, WCS, or a chain of bridges followed by a target. Equivalent to creating a coord_tf with mapCS() and applying it.