pub struct PolarCoordinates {
    pub angle: f64,
    pub radius: f64,
}
Expand description

Coordinates specified as angle and radius from the origin

Fields

angle: f64radius: f64

Implementations

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

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.