pub struct Angular { /* private fields */ }Expand description
角度物理量结构体
表示角度大小,支持弧度和度数单位
§示例
use zmatrix::physics::basic::Angular;
let angle = Angular::from_rad(std::f64::consts::PI);
println!("角度: {} 弧度", angle.as_rad());Implementations§
Source§impl Angular
impl Angular
pub fn from_rad(rad: f64) -> Self
Sourcepub fn from_deg(deg: f64) -> Self
pub fn from_deg(deg: f64) -> Self
Examples found in repository?
examples/example_physics.rs (line 26)
19fn calculate() {
20 let distance = Distance::from_m(1000.0);
21 let time = TimeDelta::seconds(10);
22 let velocity: Velocity = distance / time;
23 let acc: Acceleration = velocity / time;
24 println!("速度: {} m/s, 加速度: {} m/s²", velocity.as_m_per_sec(), acc.as_m_per_s2());
25
26 let ang: Angular = Angular::from_deg(180.0);
27 let time = TimeDelta::seconds(10);
28 let omg: AngularVelocity = ang / time;
29 let angular_accel: AngularAcceleration = omg / time;
30 println!(
31 "角速度: {} rad/s, 角加速度: {} rad/s²",
32 omg.as_rad_per_second(),
33 angular_accel.as_rad_per_second2()
34 );
35
36 let dis: Distance = Distance::from_m(1000.0);
37 let area: Area = dis * dis;
38 println!("面积: {} m²", area.as_m2());
39}pub fn as_rad(&self) -> f64
pub fn as_deg(&self) -> f64
pub fn sin(&self) -> f64
pub fn tan(&self) -> f64
pub fn cos(&self) -> f64
pub fn mod_to_round_half(&self) -> Self
pub fn mod_to_round(&self) -> Self
pub fn atan2(a: f64, b: f64) -> Self
pub fn atan(a: f64) -> Self
pub fn asin(v: f64) -> Self
pub fn acos(v: f64) -> Self
Trait Implementations§
impl Copy for Angular
Source§impl<'a> Div<&'a AngularVelocity> for Angular
impl<'a> Div<&'a AngularVelocity> for Angular
Source§impl<'a, 'b> Div<&'b AngularVelocity> for &'a Angular
impl<'a, 'b> Div<&'b AngularVelocity> for &'a Angular
Source§impl Div<AngularVelocity> for Angular
impl Div<AngularVelocity> for Angular
Source§impl<'a> Div<AngularVelocity> for &'a Angular
impl<'a> Div<AngularVelocity> for &'a Angular
impl NonCoefficient for Angular
Source§impl PhysicalQuantity for Angular
impl PhysicalQuantity for Angular
impl StructuralPartialEq for Angular
impl VectorQuantity for Angular
Auto Trait Implementations§
impl Freeze for Angular
impl RefUnwindSafe for Angular
impl Send for Angular
impl Sync for Angular
impl Unpin for Angular
impl UnsafeUnpin for Angular
impl UnwindSafe for Angular
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more