-
Notifications
You must be signed in to change notification settings - Fork 94
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
Quantity points arithmetics #668
Comments
@burnpanck, you always cared for quantity points and had good ideas on how to support those. Your feedback is welcomed here. |
I usually understand 'height' and 'width' as quantities of different (spatial) dimensions. Only if the points are defined in a common (vector) space, you can determine (vector) distances or offset them with (vector) distances of this space. However, one might be tempted to interpret the 'length' in the expression implicitly as 'belonging to' in each case: |
Yes, this is why I submitted this issue. I think that we need to fix a few things.
Right. quantity_point{isq::height(1 * m)} + 1 * m == quantity_point{isq::height(2 * m)}; A bit more interesting may be the following cases: quantity_point{1 * m} + isq::height(1 * m) == ???; // point of isq::height or any length ?
quantity_point{isq::height(1 * m)} - quantity_point{1 * m} == ???; // quantity<isq::height[m]> ? |
So it seems that This is yet another reason to consider a redesign of the |
I do care a lot about quantity points. However, in my opinion, the concept of quantity types is quite orthogonal. For me, the benefit of what we call "quantity type" (I still struggle a bit with that name) are a scheme of incrementally narrowing down the applicability. I think it should not matter here if we are talking about points or distances - if we decide that two related quantity specs are "compatible" then this also applies to their points, and vice versa. Now what should be compatible with each other? I think we have some choice here. We want to disallow obviously wrong things. We want to allow practically useful things if they are unambiguous. If you want to know the boundary length of a rectangle, you end up summing height and width. There is only one way to do that, it is unambiguous. It is, because you are adding the length of those things. (That said, the last time I participated in the discussion about quantity types, we were still classifying "sibling types" like those as incompatible). I don't think that |
@burnpanck, it is good to hear from you again 😃
It depends on what you mean by incompatible. We can't convert from
I have a hard time imagining what it means to subtract a point of |
BTW @burnpanck, you still have a few PRs open. Will you have some time to finish them soon? |
For quantities, we allow arithmetic between different quantity types:
We had something similar for quantity points, but I am starting to think, if that is correct.
For example, for lengths, quantities represent a distance/delta between two points. Adding such deltas of length measured in different ways/dimensions makes sense and is required by the ISO 80000. Quantity points of length represent a distinct point in, for example, 3D space. The same point may have many representations from different origins in this 3D space, but they all still describe exactly the same point.
Subtracting two points of
width
gives a delta ofwidth
. However, what does it mean to subtract points ofheight
andwidth
or add a delta ofwidth
to the point ofheight
?I start to think that the above should not compile. Do you agree?
The above examples contained quantities from different branches of the length hierarchy tree. What about the same branch?
A similar question to the above might be if it should be possible to define a point of
height
with the origin being a point oflength
or vice versa?Please let me know your thoughts.
The text was updated successfully, but these errors were encountered: