Skip to content

Commit

Permalink
Add new constructors for Circle and Sphere
Browse files Browse the repository at this point in the history
  • Loading branch information
Jondolf committed Jan 25, 2024
1 parent d974b82 commit 0c12551
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/bevy_math/src/primitives/dim2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ pub struct Circle {
impl Primitive2d for Circle {}

impl Circle {
/// Create a new [`Circle`] from a `radius`
#[inline(always)]
pub const fn new(radius: f32) -> Self {
Self { radius }
}

/// Finds the point on the circle that is closest to the given `point`.
///
/// If the point is outside the circle, the returned point will be on the perimeter of the circle.
Expand Down
6 changes: 6 additions & 0 deletions crates/bevy_math/src/primitives/dim3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ pub struct Sphere {
impl Primitive3d for Sphere {}

impl Sphere {
/// Create a new [`Sphere`] from a `radius`
#[inline(always)]
pub const fn new(radius: f32) -> Self {
Self { radius }
}

/// Finds the point on the sphere that is closest to the given `point`.
///
/// If the point is outside the sphere, the returned point will be on the surface of the sphere.
Expand Down

0 comments on commit 0c12551

Please sign in to comment.