pub struct PolarCoordinates {
pub angle: f64,
pub radius: f64,
}
Expand description
Coordinates specified as angle and radius from the origin
Fields§
§angle: f64
§radius: f64
Implementations§
Source§impl 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: core::f64::consts::FRAC_PI_2,
radius: 1.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: 6.123233995736766e-17,
y: 1.0,
});
assert_eq!(
PolarCoordinates {
angle: core::f64::consts::PI,
radius: 1.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: -1.0,
y: 1.2246467991473532e-16,
});
assert_eq!(
PolarCoordinates {
angle: 3.0 * core::f64::consts::FRAC_PI_2,
radius: 2.0,
}.to_rectangular_coordinates(),
RectangularCoordinates {
x: -3.6739403974420594e-16,
y: -2.0,
});
Trait Implementations§
Source§impl Clone for PolarCoordinates
impl Clone for PolarCoordinates
Source§fn clone(&self) -> PolarCoordinates
fn clone(&self) -> PolarCoordinates
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PolarCoordinates
impl Debug for PolarCoordinates
Source§impl PartialEq for PolarCoordinates
impl PartialEq for PolarCoordinates
impl StructuralPartialEq for PolarCoordinates
Auto Trait Implementations§
impl Freeze for PolarCoordinates
impl RefUnwindSafe for PolarCoordinates
impl Send for PolarCoordinates
impl Sync for PolarCoordinates
impl Unpin for PolarCoordinates
impl UnwindSafe for PolarCoordinates
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