Expand description
A ray in 3-dimensional space: a line through space with a starting point and a direction.
Any point on the ray can be found through the formula origin + t * dir
,
where t is a non-negative floating point value, which represents the distance
along the ray.
Fields
origin: Vec3
Start of the ray
dir: Vec3
Direction of the ray, normalized
Implementations
sourceimpl Ray3
impl Ray3
sourcepub const ZERO: Ray3 = Self{ origin: Vec3::ZERO, dir: Vec3::ZERO,}
pub const ZERO: Ray3 = Self{ origin: Vec3::ZERO, dir: Vec3::ZERO,}
An invalid ray, starting at the origin and going nowhere.
sourcepub fn from_origin_dir(origin: Vec3, dir: Vec3) -> Ray3
pub fn from_origin_dir(origin: Vec3, dir: Vec3) -> Ray3
dir
should be normalized
sourcepub fn offset_along_ray(&self, t: f32) -> Ray3
pub fn offset_along_ray(&self, t: f32) -> Ray3
Returns a new ray that has had its origin moved a given distance forwards along the ray.
If the ray direction is normalized then the t
parameter corresponds to the world space distance it moves.
pub fn point_along(&self, t: f32) -> Vec3
sourcepub fn closest_points(&self, other: &Ray3) -> (Vec3, Vec3)
pub fn closest_points(&self, other: &Ray3) -> (Vec3, Vec3)
Returns the line segment where self
and other
are the closest to each other.
If the rays are parallel then non-finite points are returned.
sourcepub fn closest_ts(&self, other: &Ray3) -> (f32, f32)
pub fn closest_ts(&self, other: &Ray3) -> (f32, f32)
Returns the distance along both rays which together form
line segment where self
and other
are the closest to each other.
If the rays are parallel then non-finite values are returned.
sourcepub fn intersects_plane(&self, plane: Plane3) -> Vec3
pub fn intersects_plane(&self, plane: Plane3) -> Vec3
Returns the point where the ray intersects the plane. Returns non-finite result of the ray and plane are parallel.
pub fn closest_t_to_point(&self, point: Vec3) -> f32
sourcepub fn closest_point_to_point(&self, point: Vec3) -> Vec3
pub fn closest_point_to_point(&self, point: Vec3) -> Vec3
Returns the point along the ray that is closest to the given point. The returned point may be “behind” the ray origin.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Ray3
impl<'de> Deserialize<'de> for Ray3
sourcefn deserialize<__D>(
__deserializer: __D
) -> Result<Ray3, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Ray3, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Mul<Ray3> for IsoTransform
impl Mul<Ray3> for IsoTransform
sourceimpl PartialEq<Ray3> for Ray3
impl PartialEq<Ray3> for Ray3
sourceimpl<'a_, C_> Readable<'a_, C_> for Ray3 where
C_: Context,
impl<'a_, C_> Readable<'a_, C_> for Ray3 where
C_: Context,
fn read_from<R_>(_reader_: &mut R_) -> Result<Ray3, <C_ as Context>::Error> where
R_: Reader<'a_, C_>,
fn minimum_bytes_needed() -> usize
fn read_from_buffer_with_ctx(
context: C,
buffer: &'a [u8]
) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_with_ctx(
context: C,
buffer: &'a [u8]
) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_buffer_copying_data_with_ctx(
context: C,
buffer: &[u8]
) -> Result<Self, <C as Context>::Error>
fn read_with_length_from_buffer_copying_data_with_ctx(
context: C,
buffer: &[u8]
) -> (Result<Self, <C as Context>::Error>, usize)
fn read_with_length_from_buffer_copying_data_with_ctx_mut(
context: &mut C,
buffer: &[u8]
) -> (Result<Self, <C as Context>::Error>, usize)
fn read_from_stream_unbuffered_with_ctx<S>(
context: C,
stream: S
) -> Result<Self, <C as Context>::Error> where
S: Read,
fn read_from_stream_buffered_with_ctx<S>(
context: C,
stream: S
) -> Result<Self, <C as Context>::Error> where
S: Read,
fn read_from_file_with_ctx(
context: C,
path: impl AsRef<Path>
) -> Result<Self, <C as Context>::Error>
sourceimpl Serialize for Ray3
impl Serialize for Ray3
sourcefn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<C_> Writable<C_> for Ray3 where
C_: Context,
impl<C_> Writable<C_> for Ray3 where
C_: Context,
fn write_to<T_>(&self, _writer_: &mut T_) -> Result<(), <C_ as Context>::Error> where
T_: Writer<C_> + ?Sized,
fn write_to_buffer_with_ctx(
&self,
context: C,
buffer: &mut [u8]
) -> Result<(), <C as Context>::Error>
fn write_to_buffer_with_ctx_mut(
&self,
context: &mut C,
buffer: &mut [u8]
) -> Result<(), <C as Context>::Error>
fn write_to_vec_with_ctx(
&self,
context: C
) -> Result<Vec<u8, Global>, <C as Context>::Error>
fn write_to_vec_with_ctx_mut(
&self,
context: &mut C
) -> Result<Vec<u8, Global>, <C as Context>::Error>
fn write_to_stream_with_ctx<S>(
&self,
context: C,
stream: S
) -> Result<(), <C as Context>::Error> where
S: Write,
fn write_to_file_with_ctx(
&self,
context: C,
path: impl AsRef<Path>
) -> Result<(), <C as Context>::Error>
fn bytes_needed(&self) -> Result<usize, <C as Context>::Error>
impl Copy for Ray3
impl StructuralPartialEq for Ray3
Auto Trait Implementations
impl RefUnwindSafe for Ray3
impl Send for Ray3
impl Sync for Ray3
impl Unpin for Ray3
impl UnwindSafe for Ray3
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more