Replies: 3 comments 14 replies
-
|
Hi @Cazadorro! Thanks for your interest in the library and great feedback. Until recently, I was unaware of those use cases, but they were brought to me independently of you last week. I work on the solution now. See https://mpusz.github.io/mp-units/latest/users_guide/framework_basics/the_affine_space/#range-validated-quantity-points. It is not the final version, and I already have some changes on my local computer, but it would be great if you could provide feedback on whether it is going in the right direction. I would love to work with you on a new domain-specific example or how-to guide for our docs:
I also discussed with others that we would really benefit from creating a geography-centric system of quantities and units, so people do not have to reinvent the wheel. As you probably know, I have a geography header. Let's improve it and promote it to We can start with some code in Compiler Explorer and build on it from there. Can you help to improve here? |
Beta Was this translation helpful? Give feedback.
-
|
BTW, can you share your usage experience with the library? You can do it now or wait until we finish with this request. |
Beta Was this translation helpful? Give feedback.
-
|
Hi @Cazadorro, I believe I finished the last feature needed to model your case properly today. Please check out https://mpusz.github.io/mp-units/latest/users_guide/framework_basics/the_affine_space/ and the definitions below in geographic.h: mp-units/example/include/geographic.h Lines 147 to 163 in cd578a9 mp-units/example/include/geographic.h Lines 331 to 335 in cd578a9 Of course, it is still a simple mode, and contributions are welcome. Please let me know how it works for you. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Prior to using mp-units, we developed our own angle library internally to deal with unit safety and converting between different coordinate systems (geodetic , NED, LLA, LLHAE, ECEF etc...). We've now used mp-units for a long time, and while we use it for a lot of other units, we've not found it possible to use practically with basically anything that deals with world coordinates/orientation and coordinate-based angles of measure.
Lets start with what mp-units appears to provide:
In the coordinate/orientation world however, these angles are not this simple.
In the simplest case, such as with spherical coordinates, we take a simple azimuth, elevation coordinate on a 2D sphere, Azimuth angle can be handled by radians/degrees fine, however, elevation angle does not behave like azimuth. Elevation angle is reflected at the peaks of the sphere. We represent this as an non-type template passed into our angle types in our angle library, where this angle regime is called "symmetric". This property for elevation basically says at past 90 degrees, we go to 89 degrees instead of 91 degrees.
Latitudinal coordinates also have this very same property symmetry, and unlike an arbitrary sphere, you can't just make believe and pretend you can go past 90, there isn't a longitude that corresponds to a value larger than 90 degrees.
Additionally, there's a different type of reflection, one that most people are used to, that being a system where going past 0 goes negative, until it wraps around to -180 degrees and flips to 180. This is often used with azimuth (what we will call geometric azimuth, for reasons that will become clear soon) interchangeably with 0->360 wrapping. However, in the coordinate world we can't do this. In our angle units library, we called this "mirrored" wrapping,
In addition There's different ways of representing latitude and longitude that wrap differently depending on the source. Some LL systems use positive only longitude, so there is no mirroring. We call a 0->360 wrapping (or equivalent 0->2*pi) "full" wrapping.
Along with symmetric, mirrored, and full wrapping, the default wrapping mode is "none", which enforces no wrapping scheme and is also desirable in many situations.
This alone calls for a type level encoding of each of the wrapping schemes in order to convert/compare different sources of different formats of coordinate angles. But this further is exacerbated by heading or bearing angle.
Under a geometric azimuthal scheme, 90 degrees is the equivalent of north, or forward, and as you go counter clockwise on a circle, the angle increases. However, there are a multitude of different ways of treating the north angle even on a single azimuth plane. In a different scheme we commonly found, often associated with "heading", otherwise known as "bearing". Under this regime, the zenith/forward direction becomes zero, going counter clockwise is negative, requiring a conversion in the form of 90degrees - angle to go back and forth between geometric azimuth and bearing. We say geometric azimuth here, because there are other azimuth schemes that move 0 to forward instead of to the right, but maintain counter clock wise positive (heading azimuth).
We've had to separately encode bearing along side the mirroring modes, as some units use both.
How would we encode these things inside of mp-units?
Beta Was this translation helpful? Give feedback.
All reactions