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

Adds torque module #62

Merged
merged 3 commits into from
Jun 15, 2023
Merged

Adds torque module #62

merged 3 commits into from
Jun 15, 2023

Conversation

gampleman
Copy link
Contributor

@gampleman gampleman commented Jun 15, 2023

Adding a log of some Slack conversations about some design decisions:

@gampleman
I’m considering contributing a Torque module to elm-units, but wondering about the definition. The standard unit is the Newton-Metre, which one would normally write as type alias NewtonMeters = Product Newtons Meters. This is however identical to type alias Joules = Product Newtons Meters , so the compiler won’t complain if those quantities are ever confused (and they are different physics concepts). There seems to be some ideas of defining them as Ratio Joules Radians, which makes some sense, but might be confusing (and also unclear on how to call this unit).

@ianmackenzie
My first reaction would be to just use 'Product Newton Meters' and accept the risk of confusing a torque value for a force one, but the ratio idea is interesting
It would probably be useful to see what a few reasonable kinds of calculations would look like in each form
Like obviously "compute a torque from a force and radius" is easier in one version and "compute energy from torque and angle" is easier in the other version, but what does it look like to do, say, each of those calculations using the 'wrong' representation
That said I suspect a common use of torque would be with elm-physics and similar simulations, in which case I think the 'Product Newtons Meters' version would likely be a better fit
Also some relevant discussion/thoughts in #32

@gampleman
At the moment we’re not really doing any calculations, we’re mostly using it as a way to not mix up our units. So I don’t have much perspective on this.

@ianmackenzie
I think the most straightforward answer for now is to just use 'type alias NewtonMeters = Product Newtons Meters' and accept that that will be indistinguishable from Joules...in the long term I think it could indeed be good to take the approach discussed in #32 and have every unit type be its own custom type by default, with explicit conversions to product/ratio form as needed

@ianmackenzie
Copy link
Owner

Looks good! My only request would be to add a torque section to Constants.elm with 'newtonMeter' and 'poundFoot' constants, then use the 'poundFoot' constant in Torque.elm

@gampleman
Copy link
Contributor Author

OK, done.

By definition a pound-foot is one pound-force times one foot (works out the same because the newtonMeter value is equal to 1.0)
@ianmackenzie ianmackenzie merged commit ff0f408 into ianmackenzie:master Jun 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants