OpenKalman
Classes | Static Public Attributes | List of all members
OpenKalman::interface::detail::SphericalBase< T, Min, Max, Down, d_i, a_i, i_i > Struct Template Reference

Static Public Attributes

static constexpr bool is_specialized = true
 
static constexpr auto dimension = [](const T&) { return std::integral_constant<std::size_t, 3>{}; }
 
static constexpr auto stat_dimension = [](const T&) { return std::integral_constant<std::size_t, 4>{}; }
 
static constexpr auto is_euclidean = [](const T&) { return std::false_type{}; }
 
static constexpr auto hash_code
 
static constexpr auto to_stat_space
 Maps an element to coordinates in Euclidean space. More...
 
static constexpr auto from_stat_space
 Maps a coordinate in Euclidean space to an element. More...
 
static constexpr auto wrap
 Perform modular wrapping of spherical coordinates. More...
 

Member Data Documentation

◆ from_stat_space

template<typename T, typename Min, typename Max, typename Down, std::size_t d_i, std::size_t a_i, std::size_t i_i>
constexpr auto OpenKalman::interface::detail::SphericalBase< T, Min, Max, Down, d_i, a_i, i_i >::from_stat_space
static
Initial value:
= [](const T&, auto&& data_view)
{
decltype(auto) d = collections::get<d2_i>(std::forward<decltype(data_view)>(data_view));
decltype(auto) x = collections::get<x_i>(std::forward<decltype(data_view)>(data_view));
decltype(auto) y = collections::get<y_i>(std::forward<decltype(data_view)>(data_view));
decltype(auto) z = collections::get<z_i>(std::forward<decltype(data_view)>(data_view));
using R = values::real_type_of_t<values::real_type_of_t<collections::common_collection_type_t<decltype(data_view)>>>;
constexpr auto period = values::cast_to<R>(values::operation(std::minus{}, Max{}, Min{}));
constexpr auto scale = values::operation(std::divides{}, period, values::fixed_2pi<R>{});
auto signed_scale = values::copysign(scale, values::real(y));
if constexpr (values::fixed<decltype(d)> and values::fixed<decltype(x)> and values::fixed<decltype(y)> and values::fixed<decltype(z)>)
static_assert(values::fixed<decltype(signed_scale)>);
auto hypot_xy = values::hypot(x, std::forward<decltype(y)>(y));
auto x2y2 = values::operation(std::multiplies{}, hypot_xy, hypot_xy);
auto z2 = values::operation(std::multiplies{}, z, z);
auto h = values::sqrt(values::operation(std::plus{}, x2y2, z2));
auto theta = values::operation(calc_theta{}, std::move(h), z);
auto phi = values::operation(calc_phi{}, std::move(hypot_xy), x, signed_scale);
return make_ordered_range(
std::forward<decltype(d)>(d),
std::move(theta),
values::internal::update_real_part(std::move(phi), values::operation(wrap_phi{}, values::real(phi))));
}

Maps a coordinate in Euclidean space to an element.

This function takes d, x, y, and z Cartesian coordinates representing a location on a 4D unit half-cylinder, and converts them to spherical coordinates.

◆ hash_code

template<typename T, typename Min, typename Max, typename Down, std::size_t d_i, std::size_t a_i, std::size_t i_i>
constexpr auto OpenKalman::interface::detail::SphericalBase< T, Min, Max, Down, d_i, a_i, i_i >::hash_code
static
Initial value:
= [](const T&) -> std::size_t
{
constexpr auto a = coordinates::internal::get_descriptor_hash_code(coordinates::Angle<Min, Max>{});
constexpr auto b = coordinates::internal::get_descriptor_hash_code(coordinates::Inclination<Down>{});
constexpr std::size_t f = (a_i * 2 + i_i * 3 - 2);
constexpr auto bits = std::numeric_limits<std::size_t>::digits;
if constexpr (bits < 32)
return std::integral_constant<std::size_t, (a - 0x83B0_uz) + (b - 0x83B0_uz) + f * 0x1000_uz>{};
else if constexpr (bits < 64)
return std::integral_constant<std::size_t, (a - 0x83B023AB_uz) + (b - 0x83B023AB_uz) + f * 0x10000000_uz>{};
else
return std::integral_constant<std::size_t, (a - 0x83B023AB3EEFB99A_uz) + (b - 0x83B023AB3EEFB99A_uz) + f * 0x1000000000000000_uz>{};
}

◆ to_stat_space

template<typename T, typename Min, typename Max, typename Down, std::size_t d_i, std::size_t a_i, std::size_t i_i>
constexpr auto OpenKalman::interface::detail::SphericalBase< T, Min, Max, Down, d_i, a_i, i_i >::to_stat_space
static

Maps an element to coordinates in Euclidean space.

This function takes a set of spherical coordinates and converts them to d, x, y, and z Cartesian coordinates representing a location on a unit 4D half-cylinder.

◆ wrap

template<typename T, typename Min, typename Max, typename Down, std::size_t d_i, std::size_t a_i, std::size_t i_i>
constexpr auto OpenKalman::interface::detail::SphericalBase< T, Min, Max, Down, d_i, a_i, i_i >::wrap
static
Initial value:
= [](const T&, auto&& data_view)
{
decltype(auto) d = collections::get<d_i>(std::forward<decltype(data_view)>(data_view));
decltype(auto) i = collections::get<i_i>(std::forward<decltype(data_view)>(data_view));
decltype(auto) a = collections::get<a_i>(std::forward<decltype(data_view)>(data_view));
using R = values::real_type_of_t<values::real_type_of_t<collections::common_collection_type_t<decltype(data_view)>>>;
auto d_real = values::real(values::real(d));
auto flip_d = values::signbit(d_real);
auto d_new = values::internal::update_real_part(std::forward<decltype(d)>(d), values::abs(d_real));
constexpr auto i_period = values::operation(std::multiplies{}, values::cast_to<R>(Down{}), values::fixed_value<R, 2>{});
auto i_real = values::real(values::real(i));
auto im = values::fmod(i_real, i_period);
auto iabs = values::abs(im);
auto high_i = values::operation(std::greater{}, iabs, values::cast_to<R>(Down{}));
auto flip_i = values::operation(std::not_equal_to{}, values::signbit(im), high_i);
auto i_new = values::internal::update_real_part(std::forward<decltype(i)>(i), values::operation(wrap_theta{}, flip_d, std::move(iabs)));
auto flip_a = values::operation(std::not_equal_to{}, flip_i, flip_d);
auto aw = values::operation(wrap_phi_mod{}, flip_a, values::real(values::real(a)));
auto a_new = values::internal::update_real_part(std::forward<decltype(a)>(a), aw);
return make_ordered_range(std::move(d_new), std::move(i_new), std::move(a_new));
}

Perform modular wrapping of spherical coordinates.

The wrapping operation is equivalent to mapping to, and then back from, Euclidean space.


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