11 #include <glm/glm.hpp> 28 using glm::perspective;
36 using std::numeric_limits;
37 using std::stringstream;
68 float clamp(
float value,
float _min,
float _max);
76 vector<float>
getAABB(
const vector<vec3> &vertices);
80 bool AABBOverlap(
const vec3 &_min1,
const vec3 &_max1,
const vec3 &_min2,
const vec3 &_max2);
88 float distPointToTriangle(
const vec3 &point,
const vec3 &v1,
const vec3 &v2,
const vec3 &v3);
100 float pointPlaneDistance(
const vec3 &point,
const vec3 &planePosition,
const vec3 &planeNormal);
116 bool clipPolygonToPlane(vector<vec3> &polygon,
const vec3 &plane_pos,
const vec3 &plane_normal, vector<vector<int> > &contactIDs,
unsigned int planeIndex);
120 bool buildMinkowskiFace(
const vec3 &a,
const vec3 &b,
const vec3 &b_x_a,
const vec3 &c,
const vec3 &d,
const vec3 &d_x_c);
140 vec3
closestPointOnOBB(vec3 point,
float box_dX2,
float box_dY2,
float box_dZ2, vec3 box_position, mat3 box_orientation);
vec3 pointTriangleIntersection(vec3 pt, vec3 t1, vec3 t2, vec3 t3, unsigned int &type)
Closest point on a triangle to a point.
vec3 getPos(mat4 m)
Get position from a model matrix.
bool clipPolygonToPlane(vector< vec3 > &polygon, const vec3 &plane_pos, const vec3 &plane_normal, vector< vector< int > > &contactIDs, unsigned int planeIndex)
Sutherland-Hodgeman clipping algorithm.
float pointLineIntersection(const vec3 &p3, const vec3 &p1, const vec3 &p2)
Point and line collision,.
float distPointToTriangle(const vec3 &point, const vec3 &v1, const vec3 &v2, const vec3 &v3)
Distance from a point to a triangle.
float spherePlaneCollision(vec3 sphereCentre, vec3 planeNormal, vec3 pointOnPlane)
Sphere plane collision detection.
vec3 pointLineSegmentIntersection(vec3 p, vec3 l1, vec3 l2)
Closest point on a line segment to a point.
bool buildMinkowskiFace(const vec3 &a, const vec3 &b, const vec3 &b_x_a, const vec3 &c, const vec3 &d, const vec3 &d_x_c)
Minkowski difference to early out some checks in SAT.
vec2 lineSegmentIntersection(const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4)
Collision detection between two line segments, returns t1,t2, where the closest points on each line a...
vec3 closestPointOnCircle(vec3 p, vec3 plane_position, vec3 plane_normal, float r)
Return closest point on a circle to a point, p.
vec3 pointQuadIntersection(vec3 pt, vec3 t1, vec3 t2, vec3 t3, vec3 t4)
Closest point on a quad to a point.
vec3 closestPointOnOBB(vec3 point, float box_dX2, float box_dY2, float box_dZ2, vec3 box_position, mat3 box_orientation)
Returns closest point on OBB, from point.
vector< vec3 > getAABBVertices(const vec3 &_min, const vec3 &_max)
Get the 6 vertices that define the corners of the AABB defined by the min and max points...
mat3 formOrthogonalBasis(vec3 const &v)
Given the vector, v, generate two other orthogonal vectors thus creating a coordinate frame...
vec3 closestPointOnLineSegment(vec3 A, vec3 B, vec3 point)
closest point on line segment, A, B, to point.
float pointPlaneDistance(const vec3 &point, const vec3 &planePosition, const vec3 &planeNormal)
Distance between a point and a plane.
mat3 parallelAxis(vec3 r)
Parallel Axis Theorem (Nyguen-Steiner)
float clamp(float value, float _min, float _max)
Clamp the value between the min and max values.
mat3 skewSymmetric(vec3 const &v)
Return a skew-symmetric (cross product matrix) for the vector, v.
bool AABBOverlap(const vec3 &_min1, const vec3 &_max1, const vec3 &_min2, const vec3 &_max2)
AABB collision detection.
vector< float > getAABB(const vector< vec3 > &vertices)
Return a vector of floats representing the min and max values (minX, minY, minZ, maxX, maxY, maxZ) of the input vertices.
vec3 matrixMultiply(const mat4 &m, const vec3 &v)
Multiply a matrix with a vec3.
vec3 findOrthogonal(vec3 v)
Find a vector that is orthogonal to v.
bool rayTriangleCollision(vec3 planeIntersection, vec3 planeNormal, vec3 v1, vec3 v2, vec3 v3)
Ray triangle collision detection.
mat3 orthonormalizeOrientation(mat3 m)
Normalize all vectors in the matrix, m.
vec2 closestPointsOnLineSegments(const vec3 &p1, const vec3 &p2, const vec3 &p3, const vec3 &p4)
Collision detection between two line segments, returns t1,t2, where the closest points on each line a...