[][src]Struct rg3d_core::math::ray::Ray

pub struct Ray {
    pub origin: Vec3,
    pub dir: Vec3,
}

Fields

origin: Vec3dir: Vec3

Implementations

impl Ray[src]

pub fn from_two_points(begin: &Vec3, end: &Vec3) -> Option<Ray>[src]

Creates ray from two points. May fail if begin == end.

pub fn sphere_intersection_points(
    &self,
    position: &Vec3,
    radius: f32
) -> Option<[Vec3; 2]>
[src]

Checks intersection with sphere. Returns two intersection points or none if there was no intersection.

pub fn sphere_intersection(
    &self,
    position: &Vec3,
    radius: f32
) -> Option<IntersectionResult>
[src]

pub fn is_intersect_sphere(&self, position: Vec3, radius: f32) -> bool[src]

Checks intersection with sphere.

pub fn project_point(&self, point: Vec3) -> f32[src]

Returns t factor (at pt=o+d*t equation) for projection of given point at ray

pub fn get_point(&self, t: f32) -> Vec3[src]

Returns point on ray which defined by pt=o+d*t equation.

pub fn box_intersection(
    &self,
    min: &Vec3,
    max: &Vec3
) -> Option<IntersectionResult>
[src]

pub fn box_intersection_points(
    &self,
    min: &Vec3,
    max: &Vec3
) -> Option<[Vec3; 2]>
[src]

pub fn aabb_intersection(
    &self,
    aabb: &AxisAlignedBoundingBox
) -> Option<IntersectionResult>
[src]

pub fn aabb_intersection_points(
    &self,
    aabb: &AxisAlignedBoundingBox
) -> Option<[Vec3; 2]>
[src]

pub fn plane_intersection(&self, plane: &Plane) -> f32[src]

Solves plane equation in order to find ray equation parameter. There is no intersection if result < 0.

pub fn plane_intersection_point(&self, plane: &Plane) -> Option<Vec3>[src]

pub fn triangle_intersection(&self, vertices: &[Vec3; 3]) -> Option<Vec3>[src]

pub fn cylinder_intersection(
    &self,
    pa: &Vec3,
    pb: &Vec3,
    r: f32,
    kind: CylinderKind
) -> Option<IntersectionResult>
[src]

Generic ray-cylinder intersection test.

https://mrl.nyu.edu/~dzorin/rend05/lecture2.pdf

Infinite cylinder oriented along line pa + va * t: sqr_len(q - pa - dot(va, q - pa) * va) - r ^ 2 = 0 where q - point on cylinder, substitute q with ray p + v * t: sqr_len(p - pa + vt - dot(va, p - pa + vt) * va) - r ^ 2 = 0 reduce to A * t * t + B * t + C = 0 (quadratic equation), where: A = sqr_len(v - dot(v, va) * va) B = 2 * dot(v - dot(v, va) * va, dp - dot(dp, va) * va) C = sqr_len(dp - dot(dp, va) * va) - r ^ 2 where dp = p - pa to find intersection points we have to solve quadratic equation to get root which will be t parameter of ray equation.

pub fn try_eval_points(
    &self,
    result: Option<IntersectionResult>
) -> Option<[Vec3; 2]>
[src]

pub fn capsule_intersection(
    &self,
    pa: &Vec3,
    pb: &Vec3,
    radius: f32
) -> Option<[Vec3; 2]>
[src]

#[must_use = "Method does not modify ray, instead it returns transformed copy"]pub fn transform(&self, mat: Mat4) -> Self[src]

Transforms ray using given matrix. This method is useful when you need to transform ray into some object space to simplify calculations. For example you may have mesh with lots of triangles, and in one way you would take all vertices, transform them into world space by some matrix, then do intersection test in world space. This works, but too inefficient, much more faster would be to put ray into object space and do intersection test in object space. This removes vertex*matrix multiplication and significantly improves performance.

Trait Implementations

impl Clone for Ray[src]

impl Copy for Ray[src]

impl Debug for Ray[src]

impl Default for Ray[src]

Auto Trait Implementations

impl RefUnwindSafe for Ray

impl Send for Ray

impl Sync for Ray

impl Unpin for Ray

impl UnwindSafe for Ray

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,