CGPdocs

intersection_structure

Result of a ray intersection (valid flag, position and normal of the hit point).

Fields and methods

Members of the struct intersection_structure. Most of what you do with a CGP type goes through the free functions listed below.

Fields

bool valid = falseTrue if the ray hits the shape in front of its origin, false otherwise (position and normal then keep their default values).
vec3 position = {0,0,0}3D position of the closest hit point in front of the ray origin, {0,0,0} by default.
vec3 normal = {0,0,1}Unit normal of the shape at the hit point, {0,0,1} by default.

Functions taking a intersection_structure

None.

Functions returning a intersection_structure

Compute 4

Documented on another page

  • intersection_ray_planeIntersection in front of the origin of a ray with a plane given by a point and a normal, invalid if the ray is parallel to the plane.on vec3
  • intersection_ray_sphereFirst intersection in front of the origin of a ray (unit direction expected) with a sphere, with its position and outward normal.on vec3
  • intersection_ray_spheres_closestClosest intersection of a ray with a set of spheres of common radius, the index of the hit sphere (or -1) being written to shape_index if given.on vec3
  • picking_plane_orthogonal_to_cameraIntersects the camera ray through the screen position (relative coordinates) with the plane through plane_position orthogonal to the front direction of the camera.on vec2

Operators

None.

CGP - Computer Graphics Programming.