pub struct Ellipse2D { /* private fields */ }Expand description
A 2D ellipse defined by center and two semi-axis lengths.
Parameterized as P(t) = center + a*cos(t)*u + b*sin(t)*v
where u = (cos(rotation), sin(rotation)) and v = (-sin(rotation), cos(rotation)).
Implementations§
Source§impl Ellipse2D
impl Ellipse2D
Sourcepub fn new(
center: Point2,
semi_major: f64,
semi_minor: f64,
rotation: f64,
) -> Result<Self, MathError>
pub fn new( center: Point2, semi_major: f64, semi_minor: f64, rotation: f64, ) -> Result<Self, MathError>
Creates a new 2D ellipse.
§Errors
Returns MathError::ParameterOutOfRange if either semi-axis is not positive.
Sourcepub const fn semi_major(&self) -> f64
pub const fn semi_major(&self) -> f64
Returns the semi-major axis length.
Sourcepub const fn semi_minor(&self) -> f64
pub const fn semi_minor(&self) -> f64
Returns the semi-minor axis length.
Sourcepub fn approximate_circumference(&self) -> f64
pub fn approximate_circumference(&self) -> f64
Approximate circumference using Ramanujan’s formula.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Ellipse2D
impl<'de> Deserialize<'de> for Ellipse2D
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Ellipse2D
impl RefUnwindSafe for Ellipse2D
impl Send for Ellipse2D
impl Sync for Ellipse2D
impl Unpin for Ellipse2D
impl UnsafeUnpin for Ellipse2D
impl UnwindSafe for Ellipse2D
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