[−][src]Struct rg3d_core::math::ray::Ray
Fields
origin: Vec3dir: Vec3Implementations
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]
&self,
position: &Vec3,
radius: f32
) -> Option<[Vec3; 2]>
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]
&self,
position: &Vec3,
radius: f32
) -> Option<IntersectionResult>
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]
&self,
min: &Vec3,
max: &Vec3
) -> Option<IntersectionResult>
pub fn box_intersection_points(
&self,
min: &Vec3,
max: &Vec3
) -> Option<[Vec3; 2]>[src]
&self,
min: &Vec3,
max: &Vec3
) -> Option<[Vec3; 2]>
pub fn aabb_intersection(
&self,
aabb: &AxisAlignedBoundingBox
) -> Option<IntersectionResult>[src]
&self,
aabb: &AxisAlignedBoundingBox
) -> Option<IntersectionResult>
pub fn aabb_intersection_points(
&self,
aabb: &AxisAlignedBoundingBox
) -> Option<[Vec3; 2]>[src]
&self,
aabb: &AxisAlignedBoundingBox
) -> Option<[Vec3; 2]>
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]
&self,
pa: &Vec3,
pb: &Vec3,
r: f32,
kind: CylinderKind
) -> Option<IntersectionResult>
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]
&self,
result: Option<IntersectionResult>
) -> Option<[Vec3; 2]>
pub fn capsule_intersection(
&self,
pa: &Vec3,
pb: &Vec3,
radius: f32
) -> Option<[Vec3; 2]>[src]
&self,
pa: &Vec3,
pb: &Vec3,
radius: f32
) -> Option<[Vec3; 2]>
#[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
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> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
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>,