Skip to main content

Ellipse

Type Alias Ellipse 

Source
pub type Ellipse = Hyperellipsoid<2>;
Expand description

A circle scaled along the x and y axes.

§Examples

Basic construction and methods:

use approxim::assert_relative_eq;
use hoomd_geometry::{BoundingSphereRadius, Volume, shape::Ellipse};
use std::f64::consts::PI;

let ellipse = Ellipse::with_semi_axes([1.0.try_into()?, 2.0.try_into()?]);
let bounding_radius = ellipse.bounding_sphere_radius();
let volume = ellipse.volume();

assert_eq!(bounding_radius.get(), 2.0);
assert_relative_eq!(volume, PI * 1.0 * 2.0);

Rapid ellipse-ellipse intersection testing is possible with hoomd-geometry. This check is based on a result from algebraic geometry, with the precise approach documented within the code:

use hoomd_geometry::{IntersectsAt, shape::Ellipse};
use hoomd_vector::Angle;

let long_ellipse =
    Ellipse::with_semi_axes([0.5.try_into()?, 3.0.try_into()?]);
let round_ellipse =
    Ellipse::with_semi_axes([1.0.try_into()?, 2.0.try_into()?]);

let v_ij = [
    0.0,
    long_ellipse.semi_axes()[1].get() + round_ellipse.semi_axes()[1].get()
        - 0.1,
]
.into();

assert_eq!(
    long_ellipse.intersects_at(&round_ellipse, &v_ij, &Angle::from(0.0)),
    true
);

Aliased Type§

pub struct Ellipse { /* private fields */ }