-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Angular units such as RADIAN and STERADIAN are dimensionless #257
Comments
ComparableUnit a = (ComparableUnit) MICRO(GRAM);
ComparableUnit b = (ComparableUnit) GRAM.divide(1_000_000);
assertEquals(true, a.isEquivalentTo(b));
assertEquals(true, b.isEquivalentTo(a));
[1] https://github.com/unitsofmeasurement/indriya/wiki/Unit-Equivalence |
|
@wnreynoldsWork What do you suggest to change? Both |
Well, this is a bit of a rathole. We should be careful of the fallacy of arguing from authority. I feel there are arguments supporting both sides.
So we have a paradox. Solving this paradox is definitely out of scope of this discussion (as an aside, I think the answer is that arclength of a circle and surface area on sphere of radius r are not the same as 'length' and 'area', similar to torque not being the same as energy). If you agree with my point (1), then you agree that a UOM software system should has requirements both to distinguish units with angular components and and to go from angle->arclength and solidangle->surface area. So how to fix that?
As usual, I'd be happy to contribute some stuff if it would help. |
I see problems with 3 and 4 as to making things more complicated. We already have a necessary evil of such kind with the "scale" of a quantity to deal with absolute vs. relative quantities. You're welcome to contribute beyond such issue tickets, but this area especially the RI means one has to be at least a JCP Associate member. Did you already consider that? |
I would be caution against arguments such as 'wikipedia says', but I agree that convention amongst users is an important consideration. Arguing further on the nature of a radian is probably out of scope (although interesting). I did consider a JCP membership, but sadly, my organization is not interested in spending several thousand dollars so I can contribute code. I'd be happy to write up a page or so and post it here or send it to you if you are interested. |
It's free for all now, when did your company last look at that? Even if the burden of going to your boss for the JSPA was an issue, why not join as an Associate Member? Check out https://jcp.org/en/participation/membership I know Wikipedia may not be the universal source of truth, but if there's a statement like "XYZ is a dimensionless unit" that is usually backed by something like the BIPM and SI Brochure, which is the definitive source for us. |
I agree that community standards are important. I wanted to make sure there were substantive arguments for and against, and I think there are. A quick google unearths a good conversation here: https://physics.stackexchange.com/questions/252288/are-units-of-angle-really-dimensionless/252292. I enjoy the quote: "that dimensional status is to a degree decided by convention rather than by fact". The initial poster came to the exact conclusion I did - you need dimensions on angular units if you are going to do dimensional analysis. In any case, the argument is out of scope here. The important thing is that uom is able to support this use case, which it is. I'll look into a membership and try to do a writeup. |
Well the discussion even pointed to an earlier update of the BIPM: https://www.bipm.org/en/CGPM/db/20/8/ Sure, you're welcome, if you join within a few weeks you would even be eligible to vote on the next JCP EC (where a few actively involved in JSR 385 are among the candidates ;-) |
Yup, its a standard, but as the (really quite thoughtful) discussion indicated, it can make sense to have angles dimensioned, especially in a software library, and in fact Boost, for example, does this. Anyways, horse is dead and beaten to hamburger. |
Boost, where is that? And what is the language it uses? The UCUM catalog also has a different definition of |
C++ I think I heard about it somewhere. Is there a Github repo for it? |
Boost is a massive C++ library providing tons of functionality, including uom, https://www.boost.org/. It's deeply embedded in the C++ world, certainly in my organization. |
Interesting, in fact |
From the Boost Units FAQ: https://www.boost.org/doc/libs/1_71_0/doc/html/boost_units/FAQ.html#boost_units.FAQ.Angle_Are_Units :-) |
If you look at https://www.boost.org/doc/libs/1_71_0/doc/html/boost_units/Examples.html it does however have an example: Defining a few angular quantities,
yields
where the results are also mentioned as being dimensionless. |
@dautelle or @desruisseaux can maybe provide a bit more input here, but of the top of my head the "homogeneous systems vs. heterogeneous systems" feels like applying a different |
For preventing
I agree that Wikipedia should be taken carefully, but BIPM is the result of international agreements; it is the most authoritative source I'm aware of, and the source of other standardisation bodies like NIST. Admittedly the SI dimensions result from human decisions rather than fundamental laws of nature, but BIPM worked hard in trying to come with a consistent set of dimensions. This choice does not resolve all problems (e.g. Torque has the same dimension than Energy, so those two quantities suffer from the same problem than In the particular case of radians, I think it should stay dimensionless. Otherwise as noted above, It may not be a convincing argument, but as a side note, series expansions like
But as said above, having |
Thanks for the quick reply @desruisseaux. I guess especially to refine the result if |
Example use case for isCompatible() - We've implemented an expression + unit parser for our application. Say a user enters the string: 1 {meter} + 1 {foot} meter.isCompatible(foot) == true, so the expression is allowed. It is parsed and stored into the system for execution by our system. If the user enters 1 {meter} + 1 {second} meter.isCompatible(second) == false, so an error message is displayed and the expression is rejected. |
@wnreynoldsWork thanks, but my question is rather: what would be the use case of a
What is the use case for the former instead of the later? |
I use isCompatible() for for determining if two quantities are commensurate, ie whether they have the same dimension, independent of whether they use the same units or not, I described the use case for that above. For dimensioned units, it matches my use case perfectly. Dimensionless units screw things up. So I guess you're saying that even when getCompatible() returns true, I should do a second check to see if things are compatible with ONE (ie dimensionless) and then do a third check comparing if both units are the same getSystemUnit(). But I don't think this works for my use case. For example Regarding the series expansion argument, I think you forget that your using a Taylor series, and the coefficients are the higher order derivatives, ie - the n'th coefficient is really 1/n! d^n sin(x)/dx^n *x^n, so the units cancel out and each term is dimensionless. The physics.stackexchange link mentioned above has a pretty good discussion of how functions impact the use of units (eg how to handle sin(x) = (e^ix - e^-x)/2i). My guess is that units will eventually come out in the wash, and everything works fine. (Again, fun discussion, but probably out of scope. ). I think I have a valid use case for isCompatible() that is not easily solved by other tests, but is solved by dimensioned units. While I'm sure we could come up with some baroque ways to distinguish between RADIAN and STERADIAN (and their absence: we'd need to catch (W/sr).isCompatible(W) == true), moving to dimensioned angles is a much more elegant approach. I agree with your statement that units are conventions, and that no one convetion suits everybody's needs. It is probably not worth it to break your current design to accommodate dimensioned angles, but it's nice to be able to add them in. |
There is no need to perform all those checks (test if
It will work with "1 degree + 1 radian" because those two units have "radian" as their system unit. It will differentiate "1 radian" from "1 steradian" because those two units have different system units. The current contract of |
PrintStream out = new PrintStream(System.out, true, "utf-8");
Output: so it seems to work! |
Unit meterPerDegPerSecondPerBar = Units.METRE.divide(deg).divide(Units.SECOND).divide(NonSI.BAR); Unit meterPerSrPerSecondPerBar = Units.METRE.divide(sr).divide(Units.SECOND).divide(NonSI.BAR);
m/(Pa·rad·s) so that might work. Maybe replace isCompatible() with this as an implementation? |
The problem is that current behaviour is specified by javadoc, so it is part of the method contract. It seems to me that changing the contract (before to change the implementation) would be a JSR change. Why the contract has been defined that way in the first place (why the javadoc said that |
perhaps a new method, say isSystemUnitCompatible(Unit<?> otherUnit)? If added, I'd recommend a pointer to this method from the isCompatabile() javadoc to prevent dimensionless surprises. |
Ok, first problem with this approach:
output: false. I can try my tests with something like isCompatible() || gSU.equals(gSU) |
Ok, this winds up being a deal-breaker for me due to the technical way in which I manage lookups for units. I'd been storing units in as lookup table keyed on dimension, which worked well with dimensioned angular units. I could probably get the lookup to work with several levels of checks using getSystemUnit(), but the complexity is not justified, especially given that the dimensioned approach works very well. |
The |
Can you point to a particular class and propose a PR here based on that? We just finished 385 (and were awarded for it, as well;), but even as a MR in that case (which may also allow minor API changes) certain special cases involving physical specs and standards might be a nice addition to the TCK in particular areas, at least when the SI is involved, because it's a tricky area that requires knowledge about a particular implementation, so not sure, if it's reasonable for the TCK which so far checks precisely how all interfaces are implemented, not mathematical operations or if the "Celsius Problem" is solved ;-) |
Was there any conclusion or action item here? E.g. has a ticket been created for a possible |
@desruisseaux You were the last to comment on this over 9 months ago, do you see any action item here or can it be closed? |
I have not done real analysis… The issue reported here seems valid to me, and it seems specific to Indriya implementation. So it may be a matter of running a test case in a debugger session. Maybe this is an issue that could be flagged with a "Help wanted" tag? |
As the newer #322 was closed already I am inclined to think this is also old and probably should be closed. |
Yes, I did not verified if this issue is still present today. I have no objection for closing (or other action at your choice). |
I'll check against actual changes in #322, thanks for the input. |
There is nothing more do do here, a possible improvement of Newton-metre is a separate ticket #380. |
RADIAN and STERADIAN defined in Units.java are defined as being dimensionless. This leads to strange behavior like RADIAN.isCompatible(STERADIAN) == true.
I strongly urge that new dimensions be defined for RADIAN and STERADIAN (eg PLANE_ANGLE_DIMENSION and SOLID_ANGLE_DIMENSION).
In my code, I did the following:
Thank you for writing a library that enables this sort of extension.
On a sour note, I could not mirror the code in NonSI.java to construct the above units, since the various transformer classes in tech.units.indriya.function are all package private (eg PowerOfPiConverter and RationalConverter.of()). Consequently, I request these be made public so that new units can be easily defined.
The text was updated successfully, but these errors were encountered: