[−][src]Struct smallpt::ray::Ray
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]
origin: Point<f32, U3>,
direction: Matrix<f32, U3, U1, <DefaultAllocator as Allocator<f32, U3, U1>>::Buffer>
) -> Ray
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]
&self,
a: &Point<f32, U3>,
b: &Point<f32, U3>,
c: &Point<f32, U3>
) -> Intersection
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn is_in_subset(&self) -> bool
unsafe fn to_subset_unchecked(&self) -> SS
fn from_subset(element: &SS) -> SP
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,