pub struct Segment<S> { /* private fields */ }Available on crate feature
math-utils only.Expand description
A 1-simplex or line segment in 3D space.
Creation methods should fail with a debug assertion if the points are identical.
Implementations§
Source§impl<S> Segment<S>where
S: OrderedRing,
impl<S> Segment<S>where
S: OrderedRing,
Sourcepub fn new(a: Point3<S>, b: Point3<S>) -> Option<Segment<S>>
pub fn new(a: Point3<S>, b: Point3<S>) -> Option<Segment<S>>
Returns None if the points are identical:
assert!(Segment::new ([0.0, 0.0, 1.0].into(), [0.0, 0.0, 1.0].into()).is_none());Sourcepub fn noisy(a: Point3<S>, b: Point3<S>) -> Segment<S>
pub fn noisy(a: Point3<S>, b: Point3<S>) -> Segment<S>
Panics if the points are identical:
ⓘ
let s = Segment::noisy ([0.0, 0.0, 1.0].into(), [0.0, 0.0, 1.0].into());Sourcepub fn unchecked(a: Point3<S>, b: Point3<S>) -> Segment<S>
pub fn unchecked(a: Point3<S>, b: Point3<S>) -> Segment<S>
Debug panic if the points are identical:
ⓘ
let s = Segment::unchecked ([0.0, 0.0, 1.0].into(), [0.0, 0.0, 1.0].into());pub fn from_array(_: [Point3<S>; 2]) -> Option<Segment<S>>
pub fn numcast<T>(self) -> Option<Segment<T>>
pub const fn point_a(self) -> Point3<S>
pub const fn point_b(self) -> Point3<S>
pub const fn points(self) -> [Point3<S>; 2]
Sourcepub fn point(self, param: Normalized<S>) -> Point3<S>
pub fn point(self, param: Normalized<S>) -> Point3<S>
Return a parameterized point along the segment
pub fn length(self) -> NonNegative<S>
pub fn length_squared(self) -> NonNegative<S>
Sourcepub fn perpendicular(self) -> NonZero3<S>
pub fn perpendicular(self) -> NonZero3<S>
Equivalent to self.vector().orthogonal()
pub fn translate(&mut self, displacement: Vec3<S>)
pub fn midpoint(self) -> Point3<S>where
S: Field,
pub fn aabb3(self) -> Aabb3<S>
pub fn line(self) -> Line3<S>
pub fn affine_line(self) -> Line3<S>
pub fn nearest_point(self, point: Point3<S>) -> (Normalized<S>, Point3<S>)where
S: Field,
pub fn intersect_aabb( self, aabb: Aabb3<S>, ) -> Option<((Normalized<S>, Point3<S>), (Normalized<S>, Point3<S>))>
pub fn intersect_triangle( self, triangle: Triangle<S>, ) -> Option<(Normalized<S>, Point3<S>)>
pub fn intersect_sphere( self, sphere: Sphere3<S>, ) -> Option<((Normalized<S>, Point3<S>), (Normalized<S>, Point3<S>))>
pub fn intersect_cylinder(
self,
sphere: Cylinder3<S>,
) -> Option<((Normalized<S>, Point3<S>), (Normalized<S>, Point3<S>))>where
S: Real,
pub fn intersect_capsule(
self,
capsule: Capsule3<S>,
) -> Option<((Normalized<S>, Point3<S>), (Normalized<S>, Point3<S>))>where
S: Real,
pub fn intersect_hull( self, hull: &Hull3<S>, ) -> Option<((Normalized<S>, Point3<S>), (Normalized<S>, Point3<S>))>
Trait Implementations§
Source§impl<S> PartialEq for Segment<S>where
S: PartialEq,
impl<S> PartialEq for Segment<S>where
S: PartialEq,
impl<S> Copy for Segment<S>where
S: Copy,
impl<S> Eq for Segment<S>where
S: Eq,
impl<S> StructuralPartialEq for Segment<S>
Auto Trait Implementations§
impl<S> Freeze for Segment<S>where
S: Freeze,
impl<S> RefUnwindSafe for Segment<S>where
S: RefUnwindSafe,
impl<S> Send for Segment<S>where
S: Send,
impl<S> Sync for Segment<S>where
S: Sync,
impl<S> Unpin for Segment<S>where
S: Unpin,
impl<S> UnsafeUnpin for Segment<S>where
S: UnsafeUnpin,
impl<S> UnwindSafe for Segment<S>where
S: 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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Content for Twhere
T: Copy,
impl<T> Content for Twhere
T: Copy,
Source§unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>
unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>
Prepares an output buffer, then turns this buffer into an
Owned.
User-provided closure F must only write to and not read from &mut Self.Source§fn get_elements_size() -> usize
fn get_elements_size() -> usize
Returns the size of each element.
Source§fn to_void_ptr(&self) -> *const ()
fn to_void_ptr(&self) -> *const ()
Produces a pointer to the data.
Source§fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
Builds a pointer to this type from a raw pointer.
Source§fn is_size_suitable(size: usize) -> bool
fn is_size_suitable(size: usize) -> bool
Returns true if the size is suitable to store a type like this.
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
Read this value from the supplied reader. Same as
ReadEndian::read_from_little_endian().Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.