Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for quantity_point math #570

Merged
merged 2 commits into from
May 10, 2024

Conversation

burnpanck
Copy link
Contributor

A small number of math.h operations are even well-specified for points in the affine space; I identified isfinite, isinf and isnan so far. We should eventually also support midpoint and lerp eventually - both of them are currently missing for bare quantities either. Work for another PR.

[[nodiscard]] constexpr bool isfinite(const quantity_point<R, PO, Rep>& a) noexcept
{
using std::isfinite;
return isfinite(a.quantity_ref_from(a.point_origin).numerical_value_ref_in(a.unit));
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just reuse the other overload:

Suggested change
return isfinite(a.quantity_ref_from(a.point_origin).numerical_value_ref_in(a.unit));
return isfinite(a.quantity_ref_from(a.point_origin));

Please do the same for the rest

* @return bool: Whether the quantity point is finite or not.
*/
template<auto R, auto PO, typename Rep>
requires requires(Rep v) { isfinite(v); } || requires(Rep v) { std::isfinite(v); }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe something like this?

Suggested change
requires requires(Rep v) { isfinite(v); } || requires(Rep v) { std::isfinite(v); }
requires requires(Quantity<R, Rep> q) { isfinite(q); }

Copy link
Owner

@mpusz mpusz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mpusz mpusz merged commit 9300cb7 into mpusz:master May 10, 2024
41 of 77 checks passed
@burnpanck burnpanck deleted the feature/math-for-quantity-point branch May 10, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants