User Tools

Site Tools


raycasting_line_intersections

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
raycasting_line_intersections [2023/04/13 20:03]
max created
raycasting_line_intersections [2023/04/17 16:13] (current)
max update syling on linetesting
Line 3: Line 3:
 The Raycasting namespace provides functions for testing ray intersections with various shapes. The Raycasting namespace provides functions for testing ray intersections with various shapes.
  
----- Functions ----+===== What is "Raycasting"? =====
  
-===== Raycasting::Raycast(const Sphere& a, const Ray& ray) =====+Raycasting is a technique used in real-time physics simulations and games to detect collisions between objects. It involves projecting a ray from an origin point in a certain direction, and checking if it intersects with any objects in its path.  
 + 
 +Raycasting can be used for a variety of purposes, such as detecting line-of-sight, finding the distance between two objects, and determining the surface normal of a collision. In games, it's often used to simulate realistic lighting and shadows, as well as to detect collisions between a player and the environment or other game objects. 
 + 
 +For example, in a first-person shooter game, raycasting can be used to determine whether a bullet fired by the player hits an enemy or not. Similarly, in a racing game, it can be used to detect collisions between a player's car and other objects on the track. 
 + 
 +Overall, raycasting is a powerful technique for simulating physics in real-time applications and games, and it has a wide range of practical uses.  
 + 
 +===== What's the difference between Raycasting and Linetesting? ===== 
 +Raycasting and linetesting are two common techniques, while both techniques are used to determine if a line segment intersects with any objects in a scene, they have distinct differences in their approach. 
 + 
 +The main difference between raycasting and linetesting is that raycasting uses a single point to check for intersection, whereas linetesting uses a line segment. Raycasting is also faster than linetesting because it only needs to check a single point, whereas linetesting needs to check multiple points along the line segment. However, linetesting is more accurate because it checks the entire line segment for intersections, whereas raycasting only checks for intersections along a single ray. 
 + 
 + 
 +===== Raycasting functions ===== 
 + 
 +==== Spheres ==== 
 + 
 +**Raycasting::Raycast(const Sphere& a, const Ray& ray)**
  
 Tests if a ray intersects a sphere. Tests if a ray intersects a sphere.
Line 18: Line 36:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Raycast(const AABB& aabb, const Ray& ray) =====+==== AABBs ==== 
 + 
 + 
 +**Raycasting::Raycast(const AABB& aabb, const Ray& ray)**
  
 Tests if a ray intersects an axis-aligned bounding box (AABB). Tests if a ray intersects an axis-aligned bounding box (AABB).
Line 31: Line 52:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Raycast(const OrientedBox& obb, const Ray& ray) =====+==== Oriented Boxes ==== 
 + 
 +**Raycasting::Raycast(const OrientedBox& obb, const Ray& ray) **
  
 Tests if a ray intersects an oriented bounding box (OBB). Tests if a ray intersects an oriented bounding box (OBB).
Line 44: Line 67:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Raycast(const Plane& plane, const Ray& ray) =====+==== Planes ==== 
 + 
 + 
 +**Raycasting::Raycast(const Plane& plane, const Ray& ray) **
  
 Tests if a ray intersects a plane. Tests if a ray intersects a plane.
Line 57: Line 83:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Raycast(const Triangle& triangle, const Ray& ray) =====+==== Triangles ==== 
 + 
 + 
 +**Raycasting::Raycast(const Triangle& triangle, const Ray& ray) **
  
 Tests if a ray intersects a triangle. Tests if a ray intersects a triangle.
Line 70: Line 99:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Raycast(const Mesh& mesh, const Ray& ray) =====+==== Meshes ==== 
 + 
 + 
 +**Raycasting::Raycast(const Mesh& mesh, const Ray& ray) **
  
 Tests if a ray intersects a mesh. Tests if a ray intersects a mesh.
Line 83: Line 115:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Raycast(const Entity& entity, const Ray& ray) =====+==== Entities ==== 
 + 
 +**Raycasting::Raycast(const Entity& entity, const Ray& ray) **
  
 Tests if a ray intersects an entity. Tests if a ray intersects an entity.
Line 96: Line 130:
   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.   - ''float''   - The distance along the ray where the intersection occurs. If there is no intersection, returns a negative value.
  
-===== Raycasting::Linetest(const Sphere& sphere, const Line& line) =====+===== Line testing =====  
 + 
 +==== Spheres ==== 
 + 
 +**Raycasting::Linetest(const Sphere& sphere, const Line& line) **
  
 Tests if a line intersects a sphere. Tests if a line intersects a sphere.
Line 109: Line 147:
   - ''bool''   - ''true'' if the line intersects the sphere, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the sphere, ''false'' otherwise.
  
-===== Raycasting::Linetest(const AABB& aabb, const Line& line) =====+==== AABBs ==== 
 + 
 + 
 +**Raycasting::Linetest(const AABB& aabb, const Line& line) **
  
 Tests if a line intersects an axis-aligned bounding box (AABB). Tests if a line intersects an axis-aligned bounding box (AABB).
Line 122: Line 163:
   - ''bool''   - ''true'' if the line intersects the AABB, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the AABB, ''false'' otherwise.
  
-===== Raycasting::Linetest(const OrientedBox& obb, const Line& line) =====+==== Oriented Boxes ==== 
 + 
 + 
 +**Raycasting::Linetest(const OrientedBox& obb, const Line& line) **
  
 Tests if a line intersects an oriented bounding box (OBB). Tests if a line intersects an oriented bounding box (OBB).
Line 135: Line 179:
   - ''bool''   - ''true'' if the line intersects the OBB, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the OBB, ''false'' otherwise.
  
-===== Raycasting::Linetest(const Plane& plane, const Line& line) =====+==== Planes ==== 
 + 
 + 
 +**Raycasting::Linetest(const Plane& plane, const Line& line) **
  
 Tests if a line intersects a plane. Tests if a line intersects a plane.
Line 148: Line 195:
   - ''bool''   - ''true'' if the line intersects the plane, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the plane, ''false'' otherwise.
  
-===== Raycasting::Linetest(const Triangle& triangle, const Line& line) =====+==== Triangles ==== 
 + 
 + 
 +**Raycasting::Linetest(const Triangle& triangle, const Line& line) **
  
 Tests if a line intersects a triangle. Tests if a line intersects a triangle.
Line 161: Line 211:
   - ''bool''   - ''true'' if the line intersects the triangle, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the triangle, ''false'' otherwise.
  
-===== Raycasting::Linetest(const Mesh& mesh, const Line& line) =====+==== Meshes ==== 
 + 
 + 
 +**Raycasting::Linetest(const Mesh& mesh, const Line& line) **
  
 Tests if a line intersects a mesh. Tests if a line intersects a mesh.
Line 174: Line 227:
   - ''bool''   - ''true'' if the line intersects the mesh, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the mesh, ''false'' otherwise.
  
-===== Raycasting::Linetest(const Entity& entity, const Line& line) =====+==== Entities ==== 
 + 
 + 
 +**Raycasting::Linetest(const Entity& entity, const Line& line) **
  
 Tests if a line intersects an entity. Tests if a line intersects an entity.
Line 187: Line 243:
   - ''bool''   - ''true'' if the line intersects the entity, ''false'' otherwise.   - ''bool''   - ''true'' if the line intersects the entity, ''false'' otherwise.
  
----- Support ---- 
  
-===== Raycasting::Barycentric(const Point& p, const Triangle& t) =====+===== Support Functions ===== 
 + 
 + 
 +**Raycasting::Barycentric(const Point& p, const Triangle& t)**
  
 Calculates the barycentric coordinates of a point in relation to a triangle. Calculates the barycentric coordinates of a point in relation to a triangle.
raycasting_line_intersections.1681416188.txt.gz · Last modified: 2023/04/13 20:03 by max