Skip to main content

frclib_core/units/
angular_acceleration.rs

1use crate::{unit, unit_conversion, unit_family};
2
3unit!(DegreePerSecSqr | DegreesPerSecSqr | DegsPerSecSqr: float);
4unit!(RadianPerSecSqr | RadiansPerSecSqr | RadsPerSecSqr: float);
5unit!(RotationPerSecSqr | RotationsPerSecSqr | RotsPerSecSqr: float);
6unit!(RotationPerMinSqr | RotationsPerMinSqr | RotsPerMinSqr: float);
7
8unit_conversion!(DegreePerSecSqr(float) <-> RadianPerSecSqr(float) ~ degree_per_second_squared_to_radian_per_second_squared);
9unit_conversion!(DegreePerSecSqr(float) <-> RotationPerSecSqr(float) ~ degree_per_second_squared_to_rotation_per_second_squared);
10unit_conversion!(DegreePerSecSqr(float) <-> RotationPerMinSqr(float) ~ degree_per_second_squared_to_rotation_per_minute_squared);
11unit_conversion!(RadianPerSecSqr(float) <-> RotationPerSecSqr(float) ~ radian_per_second_squared_to_rotation_per_second_squared);
12unit_conversion!(RadianPerSecSqr(float) <-> RotationPerMinSqr(float) ~ radian_per_second_squared_to_rotation_per_minute_squared);
13unit_conversion!(RotationPerSecSqr(float) <-> RotationPerMinSqr(float) ~ rotation_per_second_squared_to_rotation_per_minute_squared);
14
15unit_family!(AngleAccel(RadianPerSecSqr): DegreePerSecSqr, RotationPerSecSqr, RotationPerMinSqr);
16
17fn degree_per_second_squared_to_radian_per_second_squared(degree_per_second_squared: f64) -> f64 {
18    degree_per_second_squared.to_radians()
19}
20
21fn degree_per_second_squared_to_rotation_per_second_squared(degree_per_second_squared: f64) -> f64 {
22    degree_per_second_squared / 360.0
23}
24
25fn degree_per_second_squared_to_rotation_per_minute_squared(degree_per_second_squared: f64) -> f64 {
26    degree_per_second_squared / 360.0 * 60.0
27}
28
29fn radian_per_second_squared_to_rotation_per_second_squared(radian_per_second_squared: f64) -> f64 {
30    degree_per_second_squared_to_rotation_per_second_squared(radian_per_second_squared.to_degrees())
31}
32
33fn radian_per_second_squared_to_rotation_per_minute_squared(radian_per_second_squared: f64) -> f64 {
34    degree_per_second_squared_to_rotation_per_minute_squared(radian_per_second_squared.to_degrees())
35}
36
37fn rotation_per_second_squared_to_rotation_per_minute_squared(
38    rotation_per_second_squared: f64,
39) -> f64 {
40    rotation_per_second_squared * 60.0
41}