Replies: 3 comments 2 replies
-
|
Hi, The problem here is that we have two
We can't put them in the same namespace as they differ only by the return type. |
Beta Was this translation helpful? Give feedback.
-
|
It seems to me that the QuantityOf<angle> version of atan2() is sufficient and the QuantityOf<isq::angular_measure> is "extra/derived" and should require a user-initiated conversion either by context or explicitly. I'm just a joe-user, but that's what I expected a quantity<angle[radian]> from atan2(quantity, quantity). "radian" is obvious (over degrees, revolutions, grads) because "math" (d/dx sin(x) = cos(x) iff x is in radians). "Angle" is the most basic angular type. An angle isn't *really" dimensionless, is it? I do use "isq::angular_measure" and others when I have time to figure out which is best, but that's my problem. I "feel" that atan2(quantity, quantity) should return only have one return value in mp_units namespace. I'm free to specialize my quantities and use my own namespace so that ADL atan2() gives the special return type that I want. For example, I could call isq::atan2() when that's what I want. Angles are really fundamental to vectors, they have a magnitude *and* a direction. ADL is really fundamental to generic programming. Now is the time to figure this stuff out.
Thanks for all the hard work. I like the direction you're taking. The documentation is also impressive.
terry
…On Nov 2, 2025, 4:39 PM, at 4:39 PM, Mateusz Pusz ***@***.***> wrote:
Hi,
The problem here is that we have two `atan2` functions:
-
https://github.com/mpusz/mp-units/blob/c9d7384cc7130a6377e0e37d4c4344ff94988829/src/systems/include/mp-units/systems/si/math.h#L118-L121
-
https://github.com/mpusz/mp-units/blob/c9d7384cc7130a6377e0e37d4c4344ff94988829/src/systems/include/mp-units/systems/angular/math.h#L116-L118
We can't put them in the same namespace as they differ only by the
return type.
--
Reply to this email directly or view it on GitHub:
#737 (comment)
You are receiving this because you authored the thread.
Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
|
Smarter people than I have been discussing this for a long time. I'd just want ADL to work. I don't care which mp_units::quantity<R, radians> mp_units::atan2(quantity, quantity) returns. Pick any one. Or is there a better way for my template Vector3D class to deduce the angle type other than using the return type atan2()? Nice explanation of the problem. I didn't understand its relevance the first time I read it. The |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I was playing with my home-grown Vector and Point classes, trying to get them to work with mp-units. I wanted to deduce the angle type from the return type of atan2(y, x). If y and x are quantities, then the return type would by quantity<isq_angle[radian], double> (probably). However, ADL didn't find atan2() with quantityisq::displacement[m] arguments because atan2() and oher trig functions are in mp_units::angular (for some reason). What do you think about moving the trig functions into the mp_units namespace?
Beta Was this translation helpful? Give feedback.
All reactions