Skip to main content

frclib_core/units/
angular_velocity.rs

1use crate::{unit, unit_conversion, unit_family};
2
3unit!(DegreePerSec: float);
4unit!(RadianPerSec: float);
5unit!(RotationPerSec: float);
6unit!(RotationPerMin: float);
7
8unit_conversion!(DegreePerSec(float) <-> RadianPerSec(float) ~ degree_per_second_to_radian_per_second);
9unit_conversion!(DegreePerSec(float) <-> RotationPerSec(float) ~ degree_per_second_to_rotation_per_second);
10unit_conversion!(DegreePerSec(float) <-> RotationPerMin(float) ~ degree_per_second_to_rotation_per_minute);
11unit_conversion!(RadianPerSec(float) <-> RotationPerSec(float) ~ radian_per_second_to_rotation_per_second);
12unit_conversion!(RadianPerSec(float) <-> RotationPerMin(float) ~ radian_per_second_to_rotation_per_minute);
13unit_conversion!(RotationPerSec(float) <-> RotationPerMin(float) ~ rotation_per_second_to_rotation_per_minute);
14
15unit_family!(AngleVel(RadianPerSec): DegreePerSec, RotationPerSec, RotationPerMin);
16
17fn degree_per_second_to_radian_per_second(degree_per_second: f64) -> f64 {
18    degree_per_second.to_radians()
19}
20
21fn degree_per_second_to_rotation_per_second(degree_per_second: f64) -> f64 {
22    degree_per_second / 360.0
23}
24
25fn degree_per_second_to_rotation_per_minute(degree_per_second: f64) -> f64 {
26    degree_per_second / 360.0 * 60.0
27}
28
29fn radian_per_second_to_rotation_per_second(radian_per_second: f64) -> f64 {
30    degree_per_second_to_rotation_per_second(radian_per_second.to_degrees())
31}
32
33fn radian_per_second_to_rotation_per_minute(radian_per_second: f64) -> f64 {
34    degree_per_second_to_rotation_per_minute(radian_per_second.to_degrees())
35}
36
37fn rotation_per_second_to_rotation_per_minute(rotation_per_second: f64) -> f64 {
38    rotation_per_second * 60.0
39}