PainterQubits / Unitful.jl

Physical quantities with arbitrary units
Other
612 stars 112 forks source link

Newtonmeters are displayed in the wrong order #708

Open TS-CUBED opened 8 months ago

TS-CUBED commented 8 months ago

Unitful seems to follow the ordering of dimensions in the MLT system, but if forces are defined in Newton it does not follow the order of the FLT convention.

The unit Nm for moment is displayed as mN

TS-CUBED commented 5 months ago

Screenshot from 2024-05-19 23-22-16

sostock commented 5 months ago

Currently, units and dimensions are ordered alphabetically (by their full name, i.e., m comes before N because Meter comes before Newton alphabetically). This order is used in the internal representation, not just for printing. In my opinion, we should not change the internal representation (it might break code that relies on it), but we could re-order the units for printing.

However, I am not familiar with the conventions you mentioned (MLT, FLT). Does MLT mean that the dimensions are printed in this order? Currently they are not (𝐋 comes before 𝐌):

julia> dimension(u"N*m")
𝐋^2 𝐌 𝐓^-2
TS-CUBED commented 5 months ago

I don't know if there is a hard "law" for it. But in my experience the composed units are always presented in the MLT or FLT order:

N = kg m s^-2 J = N m = kg m^2 s^-2 W = N m s^-1 = kg m^2 s^-3

In any case the standard units for torque are all in the order [FL]: SI: Nm, US: lbf ft, lbf in, ...

Interestingly, your alphabetic ordering works out nicely in most other cases :-)

BTW: the situation is not made easier by naming common unit combinations in the LMT order, e.g., CGS or MKS (but those are all over the place with their capitalisation anyway).

TS-CUBED commented 5 months ago

Just checked in Matlab, and it's correct there (let's not dwell on the many rendering issues that violate engineering standards in that screenshot for the moment: upright for variables, italic for units? Should be the other way round, and definitely not mixed as in N and kg. Omitting the quantity just because its 1? Very questionable. Unitful and Latexify are much better there!):

image

In the case of Nm vs mN, the problem is also, that the space between the m and the N is too small to prevent my students to read it as milli-Newton :-)