[][src]Struct smallpt::ray::Ray

pub struct Ray {
    pub origin: Point<f32, U3>,
    pub direction: Matrix<f32, U3, U1, <DefaultAllocator as Allocator<f32, U3, U1>>::Buffer>,
    // some fields omitted
}

A struct which defines a ray and some of its cached values.

Fields

origin: Point<f32, U3>

The ray origin.

direction: Matrix<f32, U3, U1, <DefaultAllocator as Allocator<f32, U3, U1>>::Buffer>

The ray direction.

Methods

impl Ray[src]

pub fn new(
    origin: Point<f32, U3>,
    direction: Matrix<f32, U3, U1, <DefaultAllocator as Allocator<f32, U3, U1>>::Buffer>
) -> Ray
[src]

Creates a new Ray from an origin and a direction. direction will be normalized.

Examples

use bvh::ray::Ray;
use bvh::nalgebra::{Point3,Vector3};

let origin = Point3::new(0.0,0.0,0.0);
let direction = Vector3::new(1.0,0.0,0.0);
let ray = Ray::new(origin, direction);

assert_eq!(ray.origin, origin);
assert_eq!(ray.direction, direction);

pub fn intersects_aabb(&self, aabb: &AABB) -> bool[src]

Tests the intersection of a Ray with an AABB using the optimized algorithm from this paper.

Examples

use bvh::aabb::AABB;
use bvh::ray::Ray;
use bvh::nalgebra::{Point3,Vector3};

let origin = Point3::new(0.0,0.0,0.0);
let direction = Vector3::new(1.0,0.0,0.0);
let ray = Ray::new(origin, direction);

let point1 = Point3::new(99.9,-1.0,-1.0);
let point2 = Point3::new(100.1,1.0,1.0);
let aabb = AABB::with_bounds(point1, point2);

assert!(ray.intersects_aabb(&aabb));

pub fn intersects_aabb_naive(&self, aabb: &AABB) -> bool[src]

Naive implementation of a Ray/AABB intersection algorithm.

Examples

use bvh::aabb::AABB;
use bvh::ray::Ray;
use bvh::nalgebra::{Point3,Vector3};

let origin = Point3::new(0.0,0.0,0.0);
let direction = Vector3::new(1.0,0.0,0.0);
let ray = Ray::new(origin, direction);

let point1 = Point3::new(99.9,-1.0,-1.0);
let point2 = Point3::new(100.1,1.0,1.0);
let aabb = AABB::with_bounds(point1, point2);

assert!(ray.intersects_aabb_naive(&aabb));

pub fn intersects_aabb_branchless(&self, aabb: &AABB) -> bool[src]

Implementation of the algorithm described [here] (https://tavianator.com/fast-branchless-raybounding-box-intersections/).

Examples

use bvh::aabb::AABB;
use bvh::ray::Ray;
use bvh::nalgebra::{Point3,Vector3};

let origin = Point3::new(0.0,0.0,0.0);
let direction = Vector3::new(1.0,0.0,0.0);
let ray = Ray::new(origin, direction);

let point1 = Point3::new(99.9,-1.0,-1.0);
let point2 = Point3::new(100.1,1.0,1.0);
let aabb = AABB::with_bounds(point1, point2);

assert!(ray.intersects_aabb_branchless(&aabb));

pub fn intersects_triangle(
    &self,
    a: &Point<f32, U3>,
    b: &Point<f32, U3>,
    c: &Point<f32, U3>
) -> Intersection
[src]

Implementation of the [Möller-Trumbore triangle/ray intersection algorithm] (https://en.wikipedia.org/wiki/M%C3%B6ller%E2%80%93Trumbore_intersection_algorithm). Returns the distance to the intersection, as well as the u and v coordinates of the intersection. The distance is set to +INFINITY if the ray does not intersect the triangle, or hits it from behind.

Trait Implementations

impl Debug 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> Same<T> for T

type Output = T

Should always be Self

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

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