Skip to main content

Ray

Struct Ray 

Source
pub struct Ray<S: Scalar> { /* private fields */ }
Expand description

The points origin + t dir for t >= 0. dir has unit length, so t is a distance.

Implementations§

Source§

impl<S: Scalar> Ray<S>

Source

pub fn try_new(origin: Vector3<S>, dir: Vector3<S>) -> GeopResult<Self>

The ray from origin along dir, of any length. Fails if dir could be zero.

Source

pub fn origin(&self) -> &Vector3<S>

Source

pub fn dir(&self) -> &Vector3<S>

Unit length.

Source

pub fn at(&self, t: S) -> Vector3<S>

The point t along the ray.

Source

pub fn closest_to_point(&self, p: &Vector3<S>) -> S

How far along the ray it comes closest to p, never behind its origin.

Source

pub fn distance_to_point(&self, p: &Vector3<S>) -> (S, S)

How far the ray passes from p, and how far along it that is.

Source

pub fn distance_to_segment(&self, a: &Vector3<S>, b: &Vector3<S>) -> (S, S)

How far the ray passes from the segment a..b, and how far along the ray that is.

Source

pub fn intersect_triangle( &self, a: &Vector3<S>, b: &Vector3<S>, c: &Vector3<S>, ) -> Option<S>

How far along the ray it enters the triangle a, b, c, if it could (Möller–Trumbore).

Source

pub fn intersect_plane( &self, origin: &Vector3<S>, normal: &Vector3<S>, ) -> Option<(S, Vector3<S>)>

Where the ray meets the plane through origin normal to normal, and how far along it: None if it could run along the plane, or points away from it.

Source

pub fn intersect_uv_plane( &self, frame: &CoordinateSystem<S>, ) -> Option<(S, Vector2<S>)>

Where the ray meets frame’s u/v plane, in u/v coordinates, and how far along the ray: None if it could run along the plane, or points away from it.

Source

pub fn line_parameter( &self, at: &Vector3<S>, direction: &Vector3<S>, ) -> Option<S>

The parameter s of the point at + s direction of a line nearest the ray’s line. None if the two could be parallel, where no point of the line is nearer than another.

Trait Implementations§

Source§

impl<S: Clone + Scalar> Clone for Ray<S>

Source§

fn clone(&self) -> Ray<S>

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<S: Copy + Scalar> Copy for Ray<S>

Source§

impl<S: Debug + Scalar> Debug for Ray<S>

Source§

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

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

impl<'de, S> Deserialize<'de> for Ray<S>
where S: Scalar,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<S: PartialEq + Scalar> PartialEq for Ray<S>

Source§

fn eq(&self, other: &Ray<S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S> Serialize for Ray<S>
where S: Scalar,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<S: PartialEq + Scalar> StructuralPartialEq for Ray<S>

Auto Trait Implementations§

§

impl<S> Freeze for Ray<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for Ray<S>
where S: RefUnwindSafe,

§

impl<S> Send for Ray<S>

§

impl<S> Sync for Ray<S>

§

impl<S> Unpin for Ray<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for Ray<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for Ray<S>
where S: UnwindSafe,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.