1
// ---------------------------------------------------------
6
// General interface for collision and intersection queries.
8
// ---------------------------------------------------------
17
// --------------------------------------------------------------------------------------------------
18
// 2D continuous collision detection
19
// --------------------------------------------------------------------------------------------------
21
// x0 is the point, x1-x2 is the segment. Take care to specify x1,x2 in sorted order of index!
22
bool point_segment_collision(const Vec2d& x0, const Vec2d& xnew0, size_t index0,
23
const Vec2d& x1, const Vec2d& xnew1, size_t index1,
24
const Vec2d& x2, const Vec2d& xnew2, size_t index2);
26
bool point_segment_collision(const Vec2d& x0, const Vec2d& xnew0, size_t index0,
27
const Vec2d& x1, const Vec2d& xnew1, size_t index1,
28
const Vec2d& x2, const Vec2d& xnew2, size_t index2,
29
double& edge_alpha, Vec2d& normal, double& time, double& rel_disp);
31
// --------------------------------------------------------------------------------------------------
32
// 2D static intersection detection
33
// --------------------------------------------------------------------------------------------------
35
bool segment_segment_intersection(const Vec2d& x0, size_t index0,
36
const Vec2d& x1, size_t index1,
37
const Vec2d& x2, size_t index2,
38
const Vec2d& x3, size_t index3);
40
bool segment_segment_intersection(const Vec2d& x0, size_t index0,
41
const Vec2d& x1, size_t index1,
42
const Vec2d& x2, size_t index2,
43
const Vec2d& x3, size_t index3,
44
double &s0, double& s2 );
46
// --------------------------------------------------------------------------------------------------
47
// 3D continuous collision detection
48
// --------------------------------------------------------------------------------------------------
50
// x0 is the point, x1-x2-x3 is the triangle. Take care to specify x1,x2,x3 in sorted order of index!
51
bool point_triangle_collision(const Vec3d& x0, const Vec3d& xnew0, size_t index0,
52
const Vec3d& x1, const Vec3d& xnew1, size_t index1,
53
const Vec3d& x2, const Vec3d& xnew2, size_t index2,
54
const Vec3d& x3, const Vec3d& xnew3, size_t index3);
56
// x0 is the point, x1-x2-x3 is the triangle. Take care to specify x1,x2,x3 in sorted order of index!
57
// If there is a collision, returns true and sets bary1, bary2, bary3 to the barycentric coordinates of
58
// the collision point, sets normal to the collision point, t to the collision time, and the relative
59
// normal displacement (in terms of point 0 minus triangle 1-2-3)
60
bool point_triangle_collision(const Vec3d& x0, const Vec3d& xnew0, size_t index0,
61
const Vec3d& x1, const Vec3d& xnew1, size_t index1,
62
const Vec3d& x2, const Vec3d& xnew2, size_t index2,
63
const Vec3d& x3, const Vec3d& xnew3, size_t index3,
64
double& bary1, double& bary2, double& bary3,
66
double& relative_normal_displacement );
68
// x0-x1 and x2-x3 are the segments. Take care to specify x0,x1 and x2,x3 in sorted order of index!
69
bool segment_segment_collision(const Vec3d& x0, const Vec3d& xnew0, size_t index0,
70
const Vec3d& x1, const Vec3d& xnew1, size_t index1,
71
const Vec3d& x2, const Vec3d& xnew2, size_t index2,
72
const Vec3d& x3, const Vec3d& xnew3, size_t index3);
74
// x0-x1 and x2-x3 are the segments. Take care to specify x0,x1 and x2,x3 in sorted order of index!
75
// If there is a collision, returns true and sets bary0 and bary2 to parts of the barycentric coordinates of
76
// the collision point, sets normal to the collision point, t to the collision time, and the relative
77
// normal displacement (in terms of edge 0-1 minus edge 2-3)
78
bool segment_segment_collision(const Vec3d& x0, const Vec3d& xnew0, size_t index0,
79
const Vec3d& x1, const Vec3d& xnew1, size_t index1,
80
const Vec3d& x2, const Vec3d& xnew2, size_t index2,
81
const Vec3d& x3, const Vec3d& xnew3, size_t index3,
82
double& bary0, double& bary2,
84
double& relative_normal_displacement );
87
// --------------------------------------------------------------------------------------------------
88
// 3D static intersection detection
89
// --------------------------------------------------------------------------------------------------
91
// x0-x1 is the segment and and x2-x3-x4 is the triangle.
92
bool segment_triangle_intersection(const Vec3d& x0, size_t index0,
93
const Vec3d& x1, size_t index1,
94
const Vec3d& x2, size_t index2,
95
const Vec3d& x3, size_t index3,
96
const Vec3d& x4, size_t index4,
97
bool degenerate_counts_as_intersection,
98
bool verbose = false );
100
bool segment_triangle_intersection(const Vec3d& x0, size_t index0,
101
const Vec3d& x1, size_t index1,
102
const Vec3d& x2, size_t index2,
103
const Vec3d& x3, size_t index3,
104
const Vec3d& x4, size_t index4,
105
double& bary0, double& bary1, double& bary2, double& bary3, double& bary4,
106
bool degenerate_counts_as_intersection,
107
bool verbose = false );
110
// x0 is the point and x1-x2-x3-x4 is the tetrahedron. Order is irrelevant.
111
bool point_tetrahedron_intersection(const Vec3d& x0, size_t index0,
112
const Vec3d& x1, size_t index1,
113
const Vec3d& x2, size_t index2,
114
const Vec3d& x3, size_t index3,
115
const Vec3d& x4, size_t index4);