miniRT
By Marcelo Magalhães and Ygor G. Sena, 2023.
s_discriminant Struct Reference

This struct stores the necessary data to evaluate a ray-sphere intersection. To do that, it relies in geometry, trigonometry and the Pythagorean theorem. It's important to mention that discriminant means the number that says whether the ray intersects the sphere at all. For a detailed description, refer to: https://www.scratchapixel.com/ lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ ray-sphere-intersection.html. More...

#include <shapes.h>

Data Fields

double a
 
double b
 
double c
 
double t1
 
double t2
 
double discriminant
 

Detailed Description

This struct stores the necessary data to evaluate a ray-sphere intersection. To do that, it relies in geometry, trigonometry and the Pythagorean theorem. It's important to mention that discriminant means the number that says whether the ray intersects the sphere at all. For a detailed description, refer to: https://www.scratchapixel.com/ lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ ray-sphere-intersection.html.

Parameters
aStores a value from quadratic equation. This value is useful to identify if a ray is parallel or not to y axis of a given cylinder.
bStores b value from quadratic equation derived from geometry rules.
cStores c value from quadratic equation derived from geometry rules.
t1Stores the distance from ray's origin up to the intersection of a given ray with shape's surface. If there is only one, it means the ray intersects the shape in only one point.
t2Stores the distance from ray's origin up to the intersection of a given ray with shape's surface. The combination of positive and negative numbers of t1 and t2 will determine where the ray is intersecting the shape.
discriminantStores the information about how the ray intersects a given shape. If discriminant isless than 0, then the ray doesn't intersect the shape. If discriminant is 0, the ray intersects the shape in one place only. If the discriminant is higher than 0, the ray intersects the shape in two places.