mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
feat: point_from
extended with the case of the same origin
This commit is contained in:
@@ -142,7 +142,9 @@ public:
|
|||||||
template<PointOriginFor<quantity_spec> NewPO>
|
template<PointOriginFor<quantity_spec> NewPO>
|
||||||
[[nodiscard]] constexpr QuantityPointOf<NewPO{}> auto point_from(NewPO origin) const
|
[[nodiscard]] constexpr QuantityPointOf<NewPO{}> auto point_from(NewPO origin) const
|
||||||
{
|
{
|
||||||
if constexpr (detail::is_derived_from_specialization_of_relative_point_origin<NewPO>) {
|
if constexpr (std::is_same_v<NewPO, std::remove_const_t<decltype(point_origin)>>) {
|
||||||
|
return *this;
|
||||||
|
} else if constexpr (detail::is_derived_from_specialization_of_relative_point_origin<NewPO>) {
|
||||||
auto q = absolute() - origin.quantity_point.absolute();
|
auto q = absolute() - origin.quantity_point.absolute();
|
||||||
return quantity_point<reference, NewPO{}, typename decltype(q)::rep>(std::move(q));
|
return quantity_point<reference, NewPO{}, typename decltype(q)::rep>(std::move(q));
|
||||||
} else {
|
} else {
|
||||||
|
@@ -410,12 +410,15 @@ static_assert(quantity_point<isq::height[m], tower_peak>(quantity_point<isq::hei
|
|||||||
static_assert(quantity_point<isq::height[m], tower_peak>(quantity_point<isq::height[m], ground_level>(84 * m))
|
static_assert(quantity_point<isq::height[m], tower_peak>(quantity_point<isq::height[m], ground_level>(84 * m))
|
||||||
.relative() == 42 * m);
|
.relative() == 42 * m);
|
||||||
|
|
||||||
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(42 * m).point_from(mean_sea_level).relative() == 42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], ground_level>(42 * m).point_from(mean_sea_level).relative() == 84 * m);
|
static_assert(quantity_point<isq::height[m], ground_level>(42 * m).point_from(mean_sea_level).relative() == 84 * m);
|
||||||
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(mean_sea_level).relative() == 126 * m);
|
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(mean_sea_level).relative() == 126 * m);
|
||||||
|
|
||||||
|
static_assert(quantity_point<isq::height[m], ground_level>(84 * m).point_from(ground_level).relative() == 84 * m);
|
||||||
static_assert(quantity_point<isq::height[m], mean_sea_level>(84 * m).point_from(ground_level).relative() == 42 * m);
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(84 * m).point_from(ground_level).relative() == 42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(ground_level).relative() == 84 * m);
|
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(ground_level).relative() == 84 * m);
|
||||||
|
|
||||||
|
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(tower_peak).relative() == 42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], mean_sea_level>(42 * m).point_from(tower_peak).relative() == -42 * m);
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(42 * m).point_from(tower_peak).relative() == -42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], ground_level>(84 * m).point_from(tower_peak).relative() == 42 * m);
|
static_assert(quantity_point<isq::height[m], ground_level>(84 * m).point_from(tower_peak).relative() == 42 * m);
|
||||||
|
|
||||||
@@ -448,12 +451,15 @@ static_assert(quantity_point<isq::height[m], tower_peak>(quantity_point<isq::hei
|
|||||||
static_assert(quantity_point<isq::height[m], tower_peak>(quantity_point<isq::height[m], ground_level>(84 * m))
|
static_assert(quantity_point<isq::height[m], tower_peak>(quantity_point<isq::height[m], ground_level>(84 * m))
|
||||||
.absolute() == 126 * m);
|
.absolute() == 126 * m);
|
||||||
|
|
||||||
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(42 * m).point_from(mean_sea_level).absolute() == 42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], ground_level>(42 * m).point_from(mean_sea_level).absolute() == 84 * m);
|
static_assert(quantity_point<isq::height[m], ground_level>(42 * m).point_from(mean_sea_level).absolute() == 84 * m);
|
||||||
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(mean_sea_level).absolute() == 126 * m);
|
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(mean_sea_level).absolute() == 126 * m);
|
||||||
|
|
||||||
|
static_assert(quantity_point<isq::height[m], ground_level>(42 * m).point_from(ground_level).absolute() == 84 * m);
|
||||||
static_assert(quantity_point<isq::height[m], mean_sea_level>(84 * m).point_from(ground_level).absolute() == 84 * m);
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(84 * m).point_from(ground_level).absolute() == 84 * m);
|
||||||
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(ground_level).absolute() == 126 * m);
|
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(ground_level).absolute() == 126 * m);
|
||||||
|
|
||||||
|
static_assert(quantity_point<isq::height[m], tower_peak>(42 * m).point_from(tower_peak).absolute() == 126 * m);
|
||||||
static_assert(quantity_point<isq::height[m], mean_sea_level>(42 * m).point_from(tower_peak).absolute() == 42 * m);
|
static_assert(quantity_point<isq::height[m], mean_sea_level>(42 * m).point_from(tower_peak).absolute() == 42 * m);
|
||||||
static_assert(quantity_point<isq::height[m], ground_level>(84 * m).point_from(tower_peak).absolute() == 126 * m);
|
static_assert(quantity_point<isq::height[m], ground_level>(84 * m).point_from(tower_peak).absolute() == 126 * m);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user