Skip to main content

SurfaceSurfaceIntersection

Struct SurfaceSurfaceIntersection 

Source
pub struct SurfaceSurfaceIntersection { /* private fields */ }
Expand description

The intersection of two surfaces.

Read it through curves, contact_points, is_coincident, method, completeness, is_complete and is_empty. Intersect::intersect returns it.

§Examples

use geomcore::{Intersect, IntersectionMethod, Plane, Point, Sphere, Tolerance, Vector};

// The plane z = 1 cuts a sphere of radius 2 in one circle.
let plane = Plane::new(Point::new(0.0, 0.0, 1.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert_eq!(result.method(), IntersectionMethod::Exact);
assert!(result.is_complete() && !result.is_empty());
assert_eq!(result.curves().len(), 1);
assert!(!result.curves()[0].tangent);
assert!(result.contact_points().is_empty());
assert!(!result.is_coincident());

Implementations§

Source§

impl SurfaceSurfaceIntersection

Source

pub fn curves(&self) -> &[IntersectionCurve]

The curves along which the surfaces meet.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 1.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert_eq!(result.curves().len(), 1);
Source

pub fn contact_points(&self) -> &[Point]

The isolated points where the surfaces touch. On the numeric path, the points where marching found them touching without a curve of contact running on.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 2.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
// Tangent at the north pole.
assert_eq!(result.contact_points().len(), 1);
Source

pub fn is_coincident(&self) -> bool

Whether the surfaces are the same surface.

On the numeric path this is found from samples: every sample of each surface lies on the other, with the normals parallel. The completeness is then Completeness::Sampled. Where only one surface lies on the other (a patch on its whole surface), the result is not coincident but Incomplete, with a region covering the patch.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 1.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert!(!result.is_coincident());

// A sphere against its own B-spline form, found numerically.
let copy = sphere.to_bspline();
let result = sphere.intersect(&copy, Tolerance::DEFAULT);
assert!(result.is_coincident() && result.curves().is_empty());
assert_eq!(result.completeness(), &geomcore::Completeness::Sampled);
Source

pub fn method(&self) -> IntersectionMethod

Whether the result came from a closed form or a numeric search.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 1.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert_eq!(result.method(), geomcore::IntersectionMethod::Exact);
Source

pub fn completeness(&self) -> &Completeness<SurfaceSurfaceRegion>

Whether every piece was found, and where some may be missing if not.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 1.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert_eq!(result.completeness(), &geomcore::Completeness::Complete);
Source

pub fn is_complete(&self) -> bool

Whether every piece was found.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 1.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert!(result.is_complete());
Source

pub fn is_empty(&self) -> bool

Whether there is no curve, no contact point and no coincidence. With an incomplete result this means “found nothing”, not “nothing exists”.

§Examples
use geomcore::{Intersect, Plane, Point, Sphere, Tolerance, Vector};
let plane = Plane::new(Point::new(0.0, 0.0, 5.0), Vector::Z).unwrap();
let sphere = Sphere::new(Point::ORIGIN, 2.0).unwrap();
let result = plane.intersect(&sphere, Tolerance::DEFAULT);
assert!(result.is_empty());

Trait Implementations§

Source§

impl Clone for SurfaceSurfaceIntersection

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SurfaceSurfaceIntersection

Source§

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

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

impl PartialEq for SurfaceSurfaceIntersection

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SurfaceSurfaceIntersection

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.