pub struct Force { /* private fields */ }Expand description
The Force struct can be used to deal with force in a common way.
#Example
use measurements::Force;
use measurements::Mass;
use measurements::Acceleration;
let metric_ton = Mass::from_metric_tons(1.0);
let gravity = Acceleration::from_meters_per_second_per_second(9.81);
let force: Force = metric_ton * gravity; // F=ma
println!(
"One metric ton exerts a force of {} due to gravity",
force);Implementations§
Source§impl Force
impl Force
Sourcepub fn from_newtons(newtons: f64) -> Self
pub fn from_newtons(newtons: f64) -> Self
Create a Force from a floating point value in Newtons
Examples found in repository?
3fn main() {
4 for power in -12..12 {
5 let val: f64 = 123.456 * (10f64.powf(f64::from(power)));
6 println!("10^{}...", power);
7 println!("Temp of {0:.3} outside", Temperature::from_kelvin(val));
8 println!("Distance of {0:.3}", Length::from_meters(val));
9 println!("Pressure of {0:.3}", Pressure::from_millibars(val));
10 println!("Volume of {0:.3}", Volume::from_litres(val));
11 println!("Mass of {0:.3}", Mass::from_kilograms(val));
12 println!("Speed of {0:.3}", Speed::from_meters_per_second(val));
13 println!(
14 "Acceleration of {0:.3}",
15 Acceleration::from_meters_per_second_per_second(val)
16 );
17 println!("Energy of {0:.3}", Energy::from_joules(val));
18 println!("Power of {0:.3}", Power::from_watts(val));
19 println!("Force of {0:.3}", Force::from_newtons(val));
20 println!("Force of {0:.3}", Torque::from_newton_metres(val));
21 println!(
22 "Force of {0:.3}",
23 AngularVelocity::from_radians_per_second(val)
24 );
25 println!("Data size is {0:.3}", Data::from_octets(val));
26 }
27}Sourcepub fn from_micronewtons(micronewtons: f64) -> Self
pub fn from_micronewtons(micronewtons: f64) -> Self
Create a Force from a floating point value in Micronewtons
Sourcepub fn from_millinewtons(millinewtons: f64) -> Self
pub fn from_millinewtons(millinewtons: f64) -> Self
Create a Force from a floating point value in Millinewtons
Sourcepub fn from_pounds(pounds: f64) -> Self
pub fn from_pounds(pounds: f64) -> Self
Create a Force from a floating point value in pounds
Sourcepub fn from_poundals(poundals: f64) -> Self
pub fn from_poundals(poundals: f64) -> Self
Create a Force from a floating point value in poundals
Sourcepub fn from_kiloponds(kiloponds: f64) -> Self
pub fn from_kiloponds(kiloponds: f64) -> Self
Create a Force from a floating point value in kiloponds
Sourcepub fn from_dynes(dynes: f64) -> Self
pub fn from_dynes(dynes: f64) -> Self
Create a Force from a floating point value in Dynes
Sourcepub fn as_micronewtons(&self) -> f64
pub fn as_micronewtons(&self) -> f64
Convert this Force into a floating point value in Micronewtons
Sourcepub fn as_millinewtons(&self) -> f64
pub fn as_millinewtons(&self) -> f64
Convert this Force into a floating point value in Millinewtons
Sourcepub fn as_newtons(&self) -> f64
pub fn as_newtons(&self) -> f64
Convert this Force into a floating point value in Newtons
Sourcepub fn as_pounds(&self) -> f64
pub fn as_pounds(&self) -> f64
Convert this Force into a floating point value in pound-force (lb.f)
Sourcepub fn as_poundals(&self) -> f64
pub fn as_poundals(&self) -> f64
Convert this Force into a floating point value in poundals
Sourcepub fn as_kiloponds(&self) -> f64
pub fn as_kiloponds(&self) -> f64
Convert this Force into a floating point value in kiloponds