Expand description
A struct representing a circle via a position and radius.
Examples
use sepax2d::prelude::*;
let circle1 = Circle::new((0.0, 0.0), 2.0);
let circle2 = Circle::new((2.0, 2.0), 2.0);
let resolution = sat_collision(&circle1, &circle2);
let difference = 2.0 * (f32::sqrt(2.0) - 1.0); // 2 root 2 - 2
assert!(resolution.0 - difference < f32::EPSILON && resolution.0 - difference > -f32::EPSILON);
assert!(resolution.1 - difference < f32::EPSILON && resolution.1 - difference > -f32::EPSILON);
let polygon = Polygon::from_vertices((0.0, 3.0), vec![(0.0, 0.0), (1.0, 0.0), (1.0, -1.5), (0.0, -1.5)]);
assert!(sat_overlap(&polygon, &circle1));
assert!(sat_overlap(&circle1, &polygon));
Fields
position: (f32, f32)
radius: f32
Implementations
Trait Implementations
sourceimpl Rotate for Circle
impl Rotate for Circle
sourcefn rotate(&mut self, _angle: f32)
fn rotate(&mut self, _angle: f32)
Rotate the shape by the given angle, with the rotation counterclockwise when the Y-axis points up. Read more
sourcefn rotate_sincos(&mut self, _sin: f32, _cos: f32)
fn rotate_sincos(&mut self, _sin: f32, _cos: f32)
Rotate the shape using the given sine and cosine of an angle. Use this when you are rotating multiple shapes by the same angle and don’t want to re-calculate the trig functions. Read more
sourceimpl Shape for Circle
impl Shape for Circle
sourcefn set_position(&mut self, position: (f32, f32))
fn set_position(&mut self, position: (f32, f32))
Set the location of the shape.
sourcefn num_axes(&self) -> usize
fn num_axes(&self) -> usize
The number of axes the shape provides for testing. For polygons, it is the same as the number of vertices, but for circles it is simply one. Read more
sourcefn get_axis(&self, _index: usize, target: (f32, f32)) -> (f32, f32)
fn get_axis(&self, _index: usize, target: (f32, f32)) -> (f32, f32)
The method used to access the axes during the SAT calculations. This is used to avoid the memory allocation of a new vector or array each time we calculate collisions. Read more
sourcefn project(&self, axis: (f32, f32), normalize: bool) -> (f32, f32)
fn project(&self, axis: (f32, f32), normalize: bool) -> (f32, f32)
Getting the minimum and maximum projection of the shape onto the given axis to look for overlap. Normalize denotes whether or not the axis passed in is a unit vector to avoid repeating calculations. Read more
sourcefn needs_closest(&self, _index: usize) -> bool
fn needs_closest(&self, _index: usize) -> bool
Determine whether or not the shape needs access to the closest vertex of another shape to check collisions. Read more
impl Copy for Circle
Auto Trait Implementations
impl RefUnwindSafe for Circle
impl Send for Circle
impl Sync for Circle
impl Unpin for Circle
impl UnwindSafe for Circle
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more