pub struct Circle {
    pub position: (f32, f32),
    pub radius: f32,
}
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

Create a new circle with given position and radius.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Rotate the shape by the given angle, with the rotation counterclockwise when the Y-axis points up. Read more

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

The location of the shape in 2D space.

Set the location of the shape.

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

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

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

Determine whether or not the shape needs access to the closest vertex of another shape to check collisions. Read more

Gets the closest vertex/primary point/position to the given target, NOT the closest point on the shape. Read more

The point corresponding to the given axis, if applicable. Otherwise, position.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.