Skip to main content

AngleUnit

Trait AngleUnit 

Source
pub trait AngleUnit {
    // Required methods
    fn to_radians<T: CoordinateScalar + FromF64>(value: T) -> T;
    fn from_radians<T: CoordinateScalar + FromF64>(value: T) -> T;
}
Expand description

Unit of plane angle.

Mirrors boost::geometry::degree / boost::geometry::radian from boost/geometry/core/cs.hpp:41-51 and their role as the cs_angular_units<Cs>::type in cs.hpp:251-281. The conversion methods are the Rust analogue of the unnamed scaling factors Boost inlines inside each strategy.

§Examples

use geometry_cs::{AngleUnit, Degree, Radian};

// 180° == π rad
let rad = Degree::to_radians(180.0_f64);
assert!((rad - core::f64::consts::PI).abs() < 1e-12);

// Round-trip through Radian is the identity.
assert_eq!(Radian::to_radians(1.5_f64), 1.5);

Required Methods§

Source

fn to_radians<T: CoordinateScalar + FromF64>(value: T) -> T

Convert a value in this unit to radians.

For Radian this is the identity; for Degree it multiplies by π / 180.

Source

fn from_radians<T: CoordinateScalar + FromF64>(value: T) -> T

Convert a value in radians to this unit.

For Radian this is the identity; for Degree it multiplies by 180 / π.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§