Struct com_croftsoft_core::math::math_lib::PolarCoordinates
source · [−]Expand description
Coordinates specified as angle and radius from the origin
Fields
angle: f64
radius: f64
Implementations
sourceimpl PolarCoordinates
impl PolarCoordinates
sourcepub fn to_rectangular_coordinates(&self) -> RectangularCoordinates
pub fn to_rectangular_coordinates(&self) -> RectangularCoordinates
Converts from polar to rectangular coordinates
Examples
use com_croftsoft_core::math::math_lib::*;
assert_eq!(
PolarCoordinates {
angle: 0.0,
radius: 1.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: 1.0,
y: 0.0,
});
assert_eq!(
PolarCoordinates {
angle: std::f64::consts::FRAC_PI_2,
radius: 1.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: 6.123233995736766e-17,
y: 1.0,
});
assert_eq!(
PolarCoordinates {
angle: std::f64::consts::PI,
radius: 1.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: -1.0,
y: 1.2246467991473532e-16,
});
assert_eq!(
PolarCoordinates {
angle: 3.0 * std::f64::consts::FRAC_PI_2,
radius: 2.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: -3.6739403974420594e-16,
y: -2.0,
});
Trait Implementations
sourceimpl Clone for PolarCoordinates
impl Clone for PolarCoordinates
sourcefn clone(&self) -> PolarCoordinates
fn clone(&self) -> PolarCoordinates
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for PolarCoordinates
impl Debug for PolarCoordinates
sourceimpl PartialEq<PolarCoordinates> for PolarCoordinates
impl PartialEq<PolarCoordinates> for PolarCoordinates
sourcefn eq(&self, other: &PolarCoordinates) -> bool
fn eq(&self, other: &PolarCoordinates) -> bool
impl StructuralPartialEq for PolarCoordinates
Auto Trait Implementations
impl RefUnwindSafe for PolarCoordinates
impl Send for PolarCoordinates
impl Sync for PolarCoordinates
impl Unpin for PolarCoordinates
impl UnwindSafe for PolarCoordinates
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more