Skip to content
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

Orientational analysis / non-dimensionless angles #37

Open
Tehforsch opened this issue Dec 11, 2023 · 1 comment
Open

Orientational analysis / non-dimensionless angles #37

Tehforsch opened this issue Dec 11, 2023 · 1 comment
Labels
enhancement New feature or request unit-safety Features relating to unit safety

Comments

@Tehforsch
Copy link
Owner

Tehforsch commented Dec 11, 2023

Extracted from the discussion in #36 :

@jedbrown

Orientational analysis provides a way to handle angles and could distinguish quantities like energy and torque, which naively have the same dimensions (e.g., newton meters).

@Tehforsch

  1. If I thought this through properly, in order to implement this for scalar types, one could add another entry to the dimension struct of type
struct Dimension {
    length: i32,
    mass: i32,
    ...,
    orientation: Orientation3D,
}

where Orientation3D represents a member of the group mentioned in the article and implements multiplication in the sense of that group.
Of course, this isn't the whole solution to the problem, since the mathematical functions would have to be redefined such that, for example, sin is the identity on the orientation dimension, whereas cos takes the orientation to 1_0.
In principle, I don't see anything preventing us from doing this. However, what should be guaranteed is that a user using a unit_system without any orientational analysis does not "suffer" from this additional complexity of the inbuilt sin, cos, ... functions and can just use them as before. Maybe I am not thinking it through fully, but I think it should be possible to do both, by adding additional syntax to the unit_system macro which "enables" orientational analysis. If it is enabled, the functions will be redefined to do orientational analysis.

However, in order to support non-scalar quantities, we'd first need to support heterogeneously-dimensioned vectors, as in your #3, since the components of the vectors should have different orientations.

As a side comment, there is the simpler approach of treating angles as angles, not as dimensionless quantities as defined in SI. If I understand this correctly, this kind of analysis is a subset of what can be done with orientational analysis. It comes with a lot of the benefits such as differentiating torque and energy, making conversions between Hz and rps (i.e. between omega and f) less error prone and so on.
However, it also has some similar additional complexity, where trigonometrical functions are now not of type Dimensionless -> Dimensionless anymore, but Angle -> Dimensionless instead. This wouldn't be a problem if one only ever used angles for these, but in practice, I think this is not the case, since they appear all over the place. Some constants will also appear in two forms, such as plancks constant which comes in angular and non-angular form if I remember correctly.
For some information on this see: sharkdp/numbat#91

While it is less powerful than orientational analysis, it might still be worth thinking about providing this too, because it avoids the problem of needing dimensionally-heterogeneous vectors, if I am not mistaken.

@jedbrown

Having not used an orientational analysis or dimensional-angles system, my impulse is that dimensional angles would be easier to use while still catching many of the mistakes that the current system allows. And it should be easier to implement.

@Tehforsch Tehforsch added the enhancement New feature or request label Dec 11, 2023
@Tehforsch
Copy link
Owner Author

Tehforsch commented Dec 11, 2023

Having not used an orientational analysis or dimensional-angles system, my impulse is that dimensional angles would be easier to use while still catching many of the mistakes that the current system allows. And it should be easier to implement.

I agree. I think implementing dimensional angles is not that much work and also fits the majority of users better.
I'll look into this once I finish the refactoring I am doing right now. Orientational analysis could still be interesting in the (far?) future.

@Tehforsch Tehforsch added the unit-safety Features relating to unit safety label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request unit-safety Features relating to unit safety
Projects
None yet
Development

No branches or pull requests

1 participant