pub struct Segment2d {
    pub direction: Direction2d,
    pub half_length: f32,
}
Expand description

A segment of a line along a direction in 2D space.

Fields§

§direction: Direction2d

The direction of the line segment

§half_length: f32

Half the length of the line segment. The segment extends by this amount in both the given direction and its opposite direction

Implementations§

source§

impl Segment2d

source

pub fn new(direction: Direction2d, length: f32) -> Self

Create a new Segment2d from a direction and full length of the segment

source

pub fn from_points(point1: Vec2, point2: Vec2) -> (Self, Vec2)

Create a new Segment2d from its endpoints and compute its geometric center

§Panics

Panics if point1 == point2

source

pub fn point1(&self) -> Vec2

Get the position of the first point on the line segment

source

pub fn point2(&self) -> Vec2

Get the position of the second point on the line segment

Trait Implementations§

source§

impl Bounded2d for Segment2d

source§

fn aabb_2d(&self, translation: Vec2, rotation: f32) -> Aabb2d

Get an axis-aligned bounding box for the shape with the given translation and rotation. The rotation is in radians, counterclockwise, with 0 meaning no rotation.
source§

fn bounding_circle(&self, translation: Vec2, _rotation: f32) -> BoundingCircle

Get a bounding circle for the shape The rotation is in radians, counterclockwise, with 0 meaning no rotation.
source§

impl Clone for Segment2d

source§

fn clone(&self) -> Segment2d

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Segment2d

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for Segment2d

source§

fn eq(&self, other: &Segment2d) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for Segment2d

source§

impl Primitive2d for Segment2d

source§

impl StructuralPartialEq for Segment2d

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.