Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::Geometry Namespace Reference

Classes

struct  Triangle
 Represents a 3D triangle, equipped with some utility functions. More...
 

Functions

std::optional< float > rayBoxCollision (glm::vec3 rayOrigin, glm::vec3 rayDir, glm::vec3 cornerBotLeft, glm::vec3 cornerTopRight)
 Find the intersection time t between a ray and a box.
 
glm::vec2 detectCircleCollision (const glm::vec2 &aPos, const float &aRadius, const glm::vec2 &bPos, const float &bRadius)
 Detect if two circles overlap. If they do, output the minimum translation vector from the first circle for both to not be colliding.
 
std::optional< std::tuple< float, float > > rayUnitCircleAtOriginIntersection (const glm::vec2 &origin, const glm::vec2 &rayDirection)
 Find the entrance and exit times t between a unit circle at the origin and a ray.
 
glm::vec3 detectAACylinderCylinderCollision (float height0, float radius0, glm::vec3 pos0, float height1, float radius1, glm::vec3 pos1)
 Find the minimum translation vector for two axis-aligned cylinders. If the two cylinders are not penetrating, then return the zero vector.
 
std::optional< std::tuple< float, glm::vec3 > > movingCylinderCylinderIntersection (float height0, float radius0, glm::vec3 pos0, float height1, float radius1, glm::vec3 pos1, glm::vec3 dir)
 Find the earliest time between intersection of two cylinders, one of which is moving. It must be the case that the two cylinders are not penetrating at the start.
 
std::optional< float > unitSphereEdgeCollision (const glm::vec3 &pos, const glm::vec3 &dir, const glm::vec3 &c, const glm::vec3 &d)
 Find collision between a moving unit sphere and an edge (line segment) in 3D.
 
std::optional< float > rayUnitSphereAtOriginIntersection (const glm::vec3 &origin, const glm::vec3 &rayDirection)
 Find the intersection time t between a unit sphere at the origin and a ray.
 
std::optional< float > rayEllipsoidIntersection (const glm::vec3 &rayOrigin, const glm::vec3 &rayDirection, const glm::vec3 &position, const glm::vec3 &radius)
 Find the intersection time t between a ray and an axis-aligned ellipsoid.
 
std::optional< float > unitSphereTriangleCollision (const glm::vec3 &pos, const glm::vec3 &dir, const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c)
 Find the intersection time t between a moving unit sphere with a triangle.
 
std::optional< float > movingEllipsoidEllipsoidIntersection (const glm::vec3 &ellipsoidPos0, const glm::vec3 &ellipsoidDir0, const glm::vec3 &ellipsoidRadius0, const glm::vec3 &ellipsoidPos1, const glm::vec3 &ellipsoidRadius1)
 Find the intersection between two moving axis-aligned ellipsoids.
 
std::optional< float > ellipsoidTriangleCollision (const glm::vec3 &ellipsoidPos, const glm::vec3 &ellipsoidDir, const glm::vec3 &ellipsoidRadius, const glm::vec3 &a, const glm::vec3 &b, const glm::vec3 &c)
 Find the intersection time t between a moving ellipsoid and a triangle.
 
float detectLineSegmentCollision (const float &alo, const float &ahi, const float &blo, const float &bhi)
 Detect collision (and return minimum translation vector) of two line segments.
 
std::optional< float > rayTriangleIntersection (const glm::vec3 &origin, const glm::vec3 &rayDirection, Triangle triangle)
 Find the intersection time t where a ray and triangle intersects. Does not detect intersections to the back side of the triangle.
 
glm::vec3 getClosestPoint (const glm::vec3 pointPos, Triangle triangle)
 Find the closest point between a point and a triangle.