Trait theon::query::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,
Scalar<S>: IntrinsicOrd + Signed,
impl<S> Intersection<Aabb<S>> for Aabb<S> where
S: EuclideanSpace,
Scalar<S>: IntrinsicOrd + 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 + FiniteDimensional<N = U2>,
impl<S> Intersection<Line<S>> for Line<S> where
S: EuclideanSpace + FiniteDimensional<N = U2>,
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<U2, Output = Greater>,
impl<S> Intersection<Plane<S>> for Line<S> where
S: EuclideanSpace + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<U2, 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,
Scalar<S>: Bounded + Infinite + IntrinsicOrd + Signed,
impl<S> Intersection<Ray<S>> for Aabb<S> where
S: EuclideanSpace,
Scalar<S>: Bounded + Infinite + IntrinsicOrd + 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<U2, Output = Greater>,
Scalar<S>: Signed,
impl<S> Intersection<Ray<S>> for Plane<S> where
S: EuclideanSpace + FiniteDimensional,
<S as FiniteDimensional>::N: Cmp<U2, Output = Greater>,
Scalar<S>: Signed,
Intersection of a plane and a ray.
sourceimpl<S> Intersection<S> for Aabb<S> where
S: EuclideanSpace,
Scalar<S>: IntrinsicOrd + Signed,
impl<S> Intersection<S> for Aabb<S> where
S: EuclideanSpace,
Scalar<S>: IntrinsicOrd + Signed,
Intersection of an axis-aligned bounding box and a point.