-
Notifications
You must be signed in to change notification settings - Fork 95
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
How to address radian and steradian? #99
Comments
FWIW I separated angles into two types which I called mathematic_angle and fraction of revolution. The mathematic_angle basically consisted of radians to rational power N,D. Fraction of revolution fits well exact rational fractions of revolution for degrees, gradian minute, revolution ( rpm) etc etc. Degrees are particularly useful for literals I found it useful to have an implicit conversion from mathematic angle to/from its underlying floating point type( but not for fraction of revolution obviously!). Also implicit conversions between all the angle types. auto angle1 = units::atan2(dy,dx); |
Isn't this a duplicate of #27? |
@i-ky I do not believe so. Angular units are special. They were even considered for an official addition to extend SI base units. In fact some of the units libraries in the wild handle radian as a base unit: https://github.com/nholthaus/units/blob/master/include/units.h#L722. |
That's news to me. Do you have any suggestions where I can read about that? I'm really curious how and why would someone introduce a dimensionless unit as a base unit. Let alone two of them... I can't deny that they are special, but one can stretch "X is special" argument to infinity. For example, one might argue that % is a common (almost "standard") way of measuring discounts. #27 has a real-life example of dimensionless units used in engineering which need to be distinguished from |
I would really love to see support for radian (i.e. radian being modeled as a real dimension) in this library! Currenlty I am using a unit library which follows this approach and IMHO it is really nice to have a distinction between e.g. angular velocity [rad/s] and frequency [1/s] or between an angle in [rad] and all other dimensionless quantities. @mpusz : we chatted very briefly after your talk at CppCon in case you remember... Integrating angular units as proper units has some pitfalls that have to be considered, I don't think there is a solution which does not either surprise users that are used to "standard" physical equations or models just a small part of the problem. There are the following options:
For details, see e.g. A workaround which is similar to 2. (but does not cover all cases) would be to make [rad] disappear whenever it is multiplied with another unit in nominator / denominator, e.g. [rad/s] * [m] = [m/s] Regarding the trigonometric functions, as these expect unit-less quantities they would also accept angular quantities but implicitly divide by the special constant k introduced earlier, i.e. something like sin(x) is defined as sin(k * x) if k == 1 [rad]^-1 |
A problem with making an angle a base-unit of a quantity is that it merges angle into quantity and complicates the problem of providing angle specific operations, specifically trigonometry functions, so my guess is that it would end up being a limited partial solution, which will need to be redone at a later date with now extra backward compatibility issues. One important difference that crops up a lot between angles and other numeric types ( on the "number line") is that angles are limited to a range of one revolution, so addition of 2 degrees to 359 degrees, should maybe wrap around automatically e.g to 1 degree. Also there is a choice of representation between angles that are always positive or that have a sign, so the issue of how to handle comparison of these numerically different but equivalent angles also arises. As @mpusz says the complicating part of treating angle like numeric is that for example radian * radian --> steradian, so they show that characteristic with quantities, but are still said to be dimensionless quantities by S.I. but it should be possible to re-use much of the quantity dimension framework with angles, while making them a distinct concept. Because of the unique nature of angles, I decided to make angle types that can stand on their, and don't depend on physical quantity at all, because they don't really fit as quantities or as numeric types, but are useful as the "Rep" type of a quantity without a doubt. |
The relationship between radians and numeric is seen where in the limit as the angle goes to 0 the circular arc length -> a straight line. I made radians and steradaians( but not other angle types) implicitly convertible to/from float for this reason. I found the most important place to differentiate radians from float is for output |
@kwikius : I made an edit to the last paragraph regarding the trigonometric functions, you are right that these would also need to be changed. Not sure if you read the edit when you commented. |
I would claim quite the contrary, the most important place to differentiate radians from float is in all calculations, i.e. more on the input side :-) |
There are many quantities with length dimension, failing to distinguish them may also lead to errors / bugs. For example, you can mix up wavelength and diameter when estimating resolution of a lens. That's not the reason to introduce additional "dimensions". Let's not forget, that quantity consists of dimension/unit and representation type. I agree with @kwikius that |
Wavelength and diameter measure the same physical "thing", a length. An angle is not identical to a ratio of lengths, it is merely proportional to the quotient of arclength and radius. Here is a nice paper explaining that in detail: https://arxiv.org/pdf/1909.08389.pdf (Angles are inherently neither length ratios nor dimensionless) |
But @i-ky 's comment is correct, that some parts of the usual physical equations would need to be changed if angles are no longer considered dimensionless, see The last sentence is interesting for us: "These underlying equations could have specialised uses, for example within quantity-calculating software, where they would ensure that the software correctly handles units involving angle and frequency." |
Here is a pull request so you can play with angles. I only implemented the "as a dimension" option though |
Thank you for these links, @dwith-ts! It started to make a bit more sense after analogy with electric charge. But I'm afraid that without wide adoption of the new system, users of units library will struggle to find equations featuring η in books/papers. They will have to adopt equations on their own to implement them in code. This may lead to confusion and, consequently, bugs. Not everyone of us is a metrology expert. |
Added dim_angle, Angle concept etc. Not really for merging, but fun to play with.(The main problem is that it doesnt conform to SI) See #99 Could try adding degrees etc in same way as non-si units
Though I did angle as dimension pull request #105, I dont think that angle should be a dimension in si namespace, since in SI namespace Torque and Energy should be dimensionally equivalent, but with status quo that is not the case. Angle as dimension should be in a custom/ experimental namespace to retain compatibility with SI |
Looking at it from the other side, the fact that with angle as a dimension Torque and Energy are dimensionally different makes them nicely work with a downcasting facility 😉 |
But
Unfortunately that that is not the way it is defined in the SI, so it really is interesting now to try to understand if the previous policy of mpusz/units to rigidly follow the SI has changed? |
Here is my latest thought on this subject : Conjecture : angle is a mathematical object rather than a physical quantity Proof: axiom : A physical unit has its basis in measurement of a physical phenomena Postulate : angle is a physical quantity since function f resulting in angle (codomain of f) may involve measuring the ratio between 2 physical lengths (domain of f). but if a and b are of same scalar physical quantity type or mathematical type m = a / b m (codomain) is in the set of mathematical objects whether or not the arguments of the function involved in its construction (domain) a and b are physical quantities The same reasoning applied to number can be applied to angle ( including solid angle and plane angle) QED : angle is a mathematical object rather than a physical quantity |
This is an interesting topic as being left underspecified in SI. I do not hold the view strongly but I would love to see "angular length" as a separate base dimension. This is of course equivalent to selecting "angle" or "the number PI" as base dimension but I enjoy the fact that the base dimension still has a physical meaning, where I would select the base unit to be the circumference of a circle with radius of 1m (that is, 2 PI meters). Then the angle dimension would be derived as "angular length" over (linear) "length". Hence the SI unit m/m is clearly visible. |
@doganulus, this a really interesting approach. I am not a physics expert though. It would be great to get feedback from other experts on this too. |
Planar angles are mathematical only in the sense that historically they are defined using primitive geometry and trigonometry without regard to units. That is, trigonometric functions implicitly assume the use of radians because mathematicians are not usually concerned with the concept of physical units and dimensional analysis. See e.g. sections II and III of [1] for discussion. Thus, just because planar angles are defined based on a mathematical constant (i.e. π) rather than a physical constant of nature (e.g. Planck's constant h, Boltzmann constant k, speed of light c, etc.) does not mean that angles should not have a base unit.
I don't think this is a good idea. While this would be consistent with the current SI definition[2] and allow for deriving an angular unit from the "angular length" or "arc length" base unit, there is nothing physically different about a curved length and a "straight" length: the former is simply a generalization of the latter. The articles[3,4] posted by @dwith-ts on this matter were informative and insightful and also support this argument that arc lengths are not special with regards to planar angles. In particular, the sections "Misconception: an angle is defined as the ratio of an arc length to a radius" and "Misconception: angle measurement requires length measurement" from [3] soundly refute the idea that lengths are required for defining planar angles at all. And "The case for making angle a base quantity" from [4] makes the point that radians are directly measurable on their own and not counted. Combining these results leads one to conclude that planar angles are[1,3,4]:
A corallary then is that planar angles can be an independent base dimension
There will be a risk of confusion and misuse surrounding planar angles in scientific codes with our without a planar angle base unit. Defining the planar angle base unit requires one to modify some physical constants and equations as per [1,4]. Not defining the planar angle base unit requires one to be very careful around the use of dimensionless quantities so as to avoid conflating incoherent dimensionless quantities. Furthermore, the required explicit conversion of non-radian angle units to radians is equivalent to modifying the physical constants and equations as per [1,4], but this explicit dimensionless conversion loses the type-safety and coherence guarantees. With the angle base unit, you can do this same explicit conversion without modifying the equations and still get the type-safety and coherence guarantee. Thus, I think it is best to define planar angle radians as a base unit, as is currently done by [1] Dimensionless Units in the SI |
As has been demonstrated angle is not a physical quantity, but if you wish to make it such, you should be allowed to do so. The quantity framework should allow the user to define their own systems. Best of luck! regards |
My conjecture is that angle is a mathematical object, because it can be defined completely in a mathematical universe I agree that my proof was not complete at all. Originally it was designed to disprove the conjecture that if the arguments to a function are physical quantities, then the output must also be a physical quantity. The conjecture was being used ( somewhere above, not by yourself as far as I remember) to claim that angle is a physical quantity, so a partial success. I agree that the purpose of a units library is to try to define physical quantities as mathematical objects. The problem is that physical quantities can't be defined completely as mathematical objects since they need arbitrary measurements in the physical world to make sense, so in S.I. the so called base_units, which rely on external measurements from the physical universe. However angle can be defined completely in mathematical terms. It needs no physical stuff to be measured and tagged as its base_unit. Informally an angle with a value of 1 or Pi has a mathematical meaning. A physical quantity with a value of 1 or Pi is mathematically meaningless. |
And again, you ignore what I am saying. You don't need to prove that the angle is mathematical. Obviously you can use angles in a virtual or mathematical "universe", as is true of any other SI unit. What you need to prove is that an angle is somehow sufficiently different from other quantities and that it is not physical.
No, it is not incomplete--it is completely flawed and inconsistent.
I know what you were trying to do, and it does not work for the reasons stated in my previous post.
Yes, which is contrary to your final conclusion. If you concluded that angles are physical quantities, then we would have no disagreement.
By that same logic, you do not need a physical measurement to define a length, and you can define them as purely mathematical objects. This is not proof that angles are not physical, only that they are also mathematical, like any other unit. You continue to ignore the simplest argument for proof that angles are also physical: they can be measured and constructed in the physical world with a physical object called a protractor. Yet you insist they are different from lengths which are measured and constructed in the physical world with a physical object called a ruler.
Indeed. This is the point clearly made by [2] and myself, which only supports my argument that an angle needs a dimension so as to avoid incoherence, confusion, and ambiguity. |
Remember I did actually implement angle as dimension for you too experiment with https://github.com/mpusz/units/blob/master/example/experimental_angle.cpp All you now need to do is
|
Remember I did actually implement angle as dimension for you too experiment with https://github.com/mpusz/units/blob/master/example/experimental_angle.cpp Good luck with the rest of the implementation ! |
Dear @JohelEGP,
Dimensional analysis will not provide 100% type safety on its own. It provides a good foundation with plenty of room for more layers (quantity kinds, etc.)
Every quantity has a dimension. Even when we say "dimensionless quantity", we mean "a quantity of dimension one".
The big question causing heated debates here is whether angles should be a base dimension. |
Thank you.
I see. So the end result is whether its quantities are dimensionless or not. And all that entails. I think it (and any ratio of units that cancel out) can be made a base dimension until it's proven problematic. Making it otherwise would hinder the exploration Thanks to @kwikius, angle is already a base dimension. |
Not thanks to me Thanks to @mpusz. #105 I specifically made clear in the PR that it was not intended for inclusion in master. ;) |
Incidentally I am only concerned that angle should not be a base dimension in the S.I system mp-units implementation to conform to the S.I . If you wish to use it as such in your own system I have no objection. Personally though I have found angles to be useful in their own right and have identified 2 separate concepts of angle. I believe that making angle part of a physical quantity type template will lose that flexibility. Overall I have argued for a more concepts base approach to units which would allow such flexibility since I can write my own conforming types |
Even though I liked the initial idea it does not work in practice. However, this is off-topic here and this tread is already long and hard to follow so if we want to start this discussion I recommend a separate thread in Discussions. Coming back to angles. We had a really interesting discussion here. Thank you all for sharing your point of view. Unless there are new points of view or ideas we should probably start making some decisions on the future direction. If I am not wrong here are all the possible solutions to address the subject (if some solution is missing, please let me know and I will update this table):
The above does not mean we have to choose any of the solutions as of now. However, if we want to keep it as a viable solution for the future we have some work to do (unless we decide to follow with 4. 😉): If we fail to address any of the above issues we will have to drop a corresponding solution. If you favor any of the solutions please help in addressing its issues. Pull Requests are welcome 😃 |
Simplest option is to ignore angles for now in SI system or provide options to select which flavour the user prefers; Vanilla SI angles which means following the book as currently writte,or some custom extension SI angles . If custom just remove any parts of Vanilla that might have angles in it and pull in relevant namespace for the custom angle library. After all there are many other mathematical objects such as complex number and quaternion . It isnt necessary to provide all of them to make a useful library |
Can you explain what is the problem with conversion factor between radians and degrees? |
@mpusz I am not totally familiar with how your library is set up, but can't option 1 be used (base dimension) and simply leave out a unit definition for that dimension in the |
I have done as requested. #194 I hope you will explain there why the generic programming approach to units "doesn't work in practise" I have provided links to the implementation which to my view seems to work very well in practise. The concepts based approach could also be used to solve the radian degrees conversion issue, since it would allow various types representing angle in the library |
Dear @JadeMatrix,
Additional base dimension affects the whole dimensional analysis (in this case it is performed behind the scenes by the library). This means that equations from textbooks/papers will need some manual tuning. See #99 (comment). |
If |
I would like to keep |
I've started a discussion on this particular topic if you have not already seen it[1]. [1] #195 |
Thanks, I just got into it a few minutes ago... |
Done in V2 |
Added dim_angle, Angle concept etc. Not really for merging, but fun to play with.(The main problem is that it doesnt conform to SI) See mpusz/mp-units#99 Could try adding degrees etc in same way as non-si units
Those are officially dimensionless quantities. On the other hand, it is really handy to model them dimensions. Any opinions?
The text was updated successfully, but these errors were encountered: