Closed jkelleyrtp closed 4 years ago
The short answer is you can use ratio with a measurement unit of ratio
for unit-less quantities.
Can you provide more details about your formula? The need to create a unit-less constant is odd What's in the (...)
?
I'm making an orbital mechanics calculator and 1- and + 1 show up very frequently. It's not terribly unusual to find reduced formulas of PDEs/ODEs/trig that involve unit constants.
http://www.braeunig.us/space/orbmech.htm
These tend to be intermediate steps and I would prefer not have to derive the units on the constant, even if there aren't any.
It's not entirely clear to me on how to make a new Ratio, can you provide an example?
Here's a simple example. If this isn't working for you could you provide a minimal example of what you're trying to do.
extern crate uom;
use uom::si::f32::*;
use uom::si::ratio::ratio;
fn main() {
let _ratio = Ratio::new::<ratio>(1.0);
}
Awesome, thanks for the example. That should do the trick.
My formula follows something like sqrt( 1 - (...)). I don't see a documented way to generate the 1 with a unitless unit. My workaround is
and then using u1 as it were 1 but this is an ugly workaround. I'm not even sure how to make this const because I don't know the units of u1.