pub struct Segment2<Unit: Copy = (), Space: Copy = ()> {
pub a: Vec2<Unit, Space>,
pub b: Vec2<Unit, Space>,
}Expand description
A 2D line segment.
Fields§
§a: Vec2<Unit, Space>§b: Vec2<Unit, Space>Implementations§
Source§impl<Unit: Copy, Space: Copy> Segment2<Unit, Space>
impl<Unit: Copy, Space: Copy> Segment2<Unit, Space>
pub const fn new(a: Vec2<Unit, Space>, b: Vec2<Unit, Space>) -> Self
pub fn direction(self) -> Vec2<Unit, Space>
pub fn length_squared(self) -> f32
pub fn length(self) -> f32
pub fn point_at(self, t: f32) -> Vec2<Unit, Space>
Sourcepub fn closest_t_to_point(self, p: Vec2<Unit, Space>) -> f32
pub fn closest_t_to_point(self, p: Vec2<Unit, Space>) -> f32
Returns the clamped segment parameter t in ([0,1]) for closest point to p.
If the segment is degenerate, returns 0.
pub fn closest_point(self, p: Vec2<Unit, Space>) -> Vec2<Unit, Space>
pub fn distance_to_point(self, p: Vec2<Unit, Space>) -> f32
Trait Implementations§
Source§impl<'de, Unit, Space> Deserialize<'de> for Segment2<Unit, Space>
impl<'de, Unit, Space> Deserialize<'de> for Segment2<Unit, Space>
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<Unit: Copy + Copy, Space: Copy + Copy> Copy for Segment2<Unit, Space>
impl<Unit: Copy, Space: Copy> StructuralPartialEq for Segment2<Unit, Space>
Auto Trait Implementations§
impl<Unit, Space> Freeze for Segment2<Unit, Space>
impl<Unit, Space> RefUnwindSafe for Segment2<Unit, Space>where
Unit: RefUnwindSafe,
Space: RefUnwindSafe,
impl<Unit, Space> Send for Segment2<Unit, Space>
impl<Unit, Space> Sync for Segment2<Unit, Space>
impl<Unit, Space> Unpin for Segment2<Unit, Space>
impl<Unit, Space> UnwindSafe for Segment2<Unit, Space>where
Unit: UnwindSafe,
Space: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more