Skip to main content

Angular

Struct Angular 

Source
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

Source

pub fn from_rad(rad: f64) -> Self

Source

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}
Source

pub fn as_rad(&self) -> f64

Source

pub fn as_deg(&self) -> f64

Source

pub fn sin(&self) -> f64

Source

pub fn tan(&self) -> f64

Source

pub fn cos(&self) -> f64

Source

pub fn mod_to_round_half(&self) -> Self

Source

pub fn mod_to_round(&self) -> Self

Source

pub fn atan2(a: f64, b: f64) -> Self

Source

pub fn atan(a: f64) -> Self

Source

pub fn asin(v: f64) -> Self

Source

pub fn acos(v: f64) -> Self

Trait Implementations§

Source§

impl Add for Angular

Source§

type Output = Angular

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a Angular> for Angular

Source§

type Output = Angular

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'a Angular) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, 'b> Add<&'b Angular> for &'a Angular

Source§

type Output = Angular

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &'b Angular) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<Angular> for &'a Angular

Source§

type Output = Angular

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Angular) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<f64> for Angular

Source§

type Output = Angular

The resulting type after applying the + operator.
Source§

fn add(self, rhs: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Clone for Angular

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Angular

Source§

impl Debug for Angular

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Angular

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Angular

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Div<&'a AngularVelocity> for Angular

Source§

type Output = TimeDelta

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a AngularVelocity) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a TimeDelta> for Angular

Source§

type Output = AngularVelocity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'a TimeDelta) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, 'b> Div<&'b AngularVelocity> for &'a Angular

Source§

type Output = TimeDelta

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'b AngularVelocity) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a, 'b> Div<&'b TimeDelta> for &'a Angular

Source§

type Output = AngularVelocity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &'b TimeDelta) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Angular> for f64

Source§

type Output = Angular

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Angular) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<AngularVelocity> for Angular

Source§

type Output = TimeDelta

The resulting type after applying the / operator.
Source§

fn div(self, rhs: AngularVelocity) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<AngularVelocity> for &'a Angular

Source§

type Output = TimeDelta

The resulting type after applying the / operator.
Source§

fn div(self, rhs: AngularVelocity) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Coef> for Angular

Source§

type Output = Angular

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Coef) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<TimeDelta> for Angular

Source§

type Output = AngularVelocity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: TimeDelta) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<TimeDelta> for &'a Angular

Source§

type Output = AngularVelocity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: TimeDelta) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<f64> for Angular

Source§

type Output = Angular

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl From<Angular> for Coef

Source§

fn from(value: Angular) -> Self

Converts to this type from the input type.
Source§

impl From<Coef> for Angular

Source§

fn from(value: Coef) -> Self

Converts to this type from the input type.
Source§

impl Mul<Angular> for f64

Source§

type Output = Angular

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angular) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Angular> for Coef

Source§

type Output = Angular

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Angular) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Coef> for Angular

Source§

type Output = Angular

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Coef) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<f64> for Angular

Source§

type Output = Angular

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Neg for Angular

Source§

type Output = Angular

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl NonCoefficient for Angular

Source§

impl PartialEq for Angular

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PhysicalQuantity for Angular

Source§

fn as_any(&self) -> &dyn Any

Source§

fn is_zero(&self) -> bool

Source§

fn default_unit_value(&self) -> f64

Source§

fn set_value(&mut self, value: f64)

Source§

fn unit_display_name(&self) -> String

返回物理量名称和单位,如 “Distance (m)”, “Velocity (m/s)”
Source§

impl StructuralPartialEq for Angular

Source§

impl Sub for Angular

Source§

type Output = Angular

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a Angular> for Angular

Source§

type Output = Angular

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'a Angular) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, 'b> Sub<&'b Angular> for &'a Angular

Source§

type Output = Angular

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &'b Angular) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<Angular> for &'a Angular

Source§

type Output = Angular

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Angular) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<f64> for Angular

Source§

type Output = Angular

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl VectorQuantity for Angular

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V