Skip to main content

Circle

Type Alias Circle 

Source
pub type Circle = Hypersphere<2>;
Expand description

A circle in two dimensions.

§Examples

Basic construction and methods:

use hoomd_geometry::{Volume, shape::Circle};
use hoomd_vector::Cartesian;
use std::f64::consts::PI;

let circle = Circle {
    radius: 2.0.try_into()?,
};
let volume = circle.volume();

assert_eq!(volume, PI * 4.0);

Test for intersections:

use hoomd_geometry::{IntersectsAt, shape::Circle};
use hoomd_vector::{Angle, Cartesian};

let circle = Circle {
    radius: 1.0.try_into()?,
};

assert_eq!(
    circle.intersects_at(
        &circle,
        &Cartesian::from([2.1, 0.0]),
        &Angle::default()
    ),
    false
);
assert_eq!(
    circle.intersects_at(
        &circle,
        &Cartesian::from([0.0, 1.9]),
        &Angle::default()
    ),
    true
);

Aliased Type§

pub struct Circle {
    pub radius: PositiveReal,
}

Fields§

§radius: PositiveReal

Radius of the sphere