Trait plexus::geometry::Intersection
source · [−]pub trait Intersection<T> {
type Output;
fn intersection(&self, other: &T) -> Option<Self::Output>;
}
Expand description
Intersection of geometric objects.
Determines if a pair of objects intersects and produces data describing the
intersection. Each set of objects produces its own intersection data as the
Output
type.
A symmetrical implementation is provided for heterogeneous pairs:
// These queries are equivalent.
if let Some(LinePlane::TimeOfImpact(t)) = line.intersection(&plane) { /* ... */ }
if let Some(LinePlane::TimeOfImpact(t)) = plane.intersection(&line) { /* ... */ }
Examples
Testing for intersection of an axis-aligned bounding box and a ray:
use nalgebra::Point2;
use theon::query::{Aabb, Intersection, Ray, Unit};
use theon::space::{EuclideanSpace, VectorSpace};
type E2 = Point2<f64>;
let aabb = Aabb::<E2> {
origin: EuclideanSpace::from_xy(1.0, -1.0),
extent: VectorSpace::from_xy(2.0, 2.0),
};
let ray = Ray::<E2> {
origin: EuclideanSpace::origin(),
direction: Unit::x(),
};
if let Some((min, max)) = ray.intersection(&aabb) {
// ...
}
Required Associated Types
Required Methods
fn intersection(&self, other: &T) -> Option<Self::Output>
Implementors
sourceimpl<S> Intersection<Aabb<S>> for Aabb<S> where
S: EuclideanSpace,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: IntrinsicOrd,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
impl<S> Intersection<Aabb<S>> for Aabb<S> where
S: EuclideanSpace,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: IntrinsicOrd,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
Intersection of axis-aligned bounding boxes.
sourceimpl<S> Intersection<Aabb<S>> for Ray<S> where
S: EuclideanSpace,
Aabb<S>: Intersection<Ray<S>>,
impl<S> Intersection<Aabb<S>> for Ray<S> where
S: EuclideanSpace,
Aabb<S>: Intersection<Ray<S>>,
Symmetrical intersection.
type Output = <Aabb<S> as Intersection<Ray<S>>>::Output
sourceimpl<S> Intersection<Aabb<S>> for S where
S: EuclideanSpace,
Aabb<S>: Intersection<S>,
impl<S> Intersection<Aabb<S>> for S where
S: EuclideanSpace,
Aabb<S>: Intersection<S>,
Symmetrical intersection.
type Output = <Aabb<S> as Intersection<S>>::Output
sourceimpl<S> Intersection<Line<S>> for Line<S> where
S: EuclideanSpace<N = UInt<UInt<UTerm, B1>, B0>> + FiniteDimensional,
impl<S> Intersection<Line<S>> for Line<S> where
S: EuclideanSpace<N = UInt<UInt<UTerm, B1>, B0>> + FiniteDimensional,
Intersection of lines in two dimensions.
sourceimpl<S> Intersection<Line<S>> for Plane<S> where
S: EuclideanSpace,
Line<S>: Intersection<Plane<S>>,
impl<S> Intersection<Line<S>> for Plane<S> where
S: EuclideanSpace,
Line<S>: Intersection<Plane<S>>,
Symmetrical intersection.
type Output = <Line<S> as Intersection<Plane<S>>>::Output
sourceimpl<S> Intersection<Plane<S>> for Line<S> where
S: EuclideanSpace + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UInt<UInt<UTerm, B1>, B0>>,
<<S as FiniteDimensional>::N as Cmp<UInt<UInt<UTerm, B1>, B0>>>::Output == Greater,
impl<S> Intersection<Plane<S>> for Line<S> where
S: EuclideanSpace + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UInt<UInt<UTerm, B1>, B0>>,
<<S as FiniteDimensional>::N as Cmp<UInt<UInt<UTerm, B1>, B0>>>::Output == Greater,
Intersection of a line and a plane.
sourceimpl<S> Intersection<Plane<S>> for Ray<S> where
S: EuclideanSpace,
Plane<S>: Intersection<Ray<S>>,
impl<S> Intersection<Plane<S>> for Ray<S> where
S: EuclideanSpace,
Plane<S>: Intersection<Ray<S>>,
Symmetrical intersection.
type Output = <Plane<S> as Intersection<Ray<S>>>::Output
sourceimpl<S> Intersection<Ray<S>> for Aabb<S> where
S: EuclideanSpace,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Bounded,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Infinite,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: IntrinsicOrd,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
impl<S> Intersection<Ray<S>> for Aabb<S> where
S: EuclideanSpace,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Bounded,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Infinite,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: IntrinsicOrd,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
Intersection of an axis-aligned bounding box and a ray.
type Output = (<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar, <<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar)
sourceimpl<S> Intersection<Ray<S>> for Plane<S> where
S: EuclideanSpace + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UInt<UInt<UTerm, B1>, B0>>,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
<<S as FiniteDimensional>::N as Cmp<UInt<UInt<UTerm, B1>, B0>>>::Output == Greater,
impl<S> Intersection<Ray<S>> for Plane<S> where
S: EuclideanSpace + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<UInt<UInt<UTerm, B1>, B0>>,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
<<S as FiniteDimensional>::N as Cmp<UInt<UInt<UTerm, B1>, B0>>>::Output == Greater,
Intersection of a plane and a ray.
sourceimpl<S> Intersection<S> for Aabb<S> where
S: EuclideanSpace,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: IntrinsicOrd,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
impl<S> Intersection<S> for Aabb<S> where
S: EuclideanSpace,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: IntrinsicOrd,
<<S as EuclideanSpace>::CoordinateSpace as VectorSpace>::Scalar: Signed,
Intersection of an axis-aligned bounding box and a point.