Ntreev Soft (in-house training) 1 Collision Detection In 3D Environments
Collision DetectionIn 3D Environments
이웅수[email protected]@gmail.com
Ntreev Soft Co. Ltd.
v0.2
Ntreev Soft (in-house training) 2 Collision Detection In 3D Environments
Notice
• 본문서를외부에유포하지말아주세요.• 본문서는 2004년 7월 23일현재 v0.1 입니다.• 본문서는 2004년 7월 29일현재 v0.2 입니다.• 본문서에포함된도안들중많은부분은여러다른저자(Bibliography & People)들의 paper를참고하거나그것으로부터발췌한것입니다. 그
들의관용을바랍니다.
Beauty is our business.
– Edsger W. Dijkstra
Ntreev Soft (in-house training) 3 Collision Detection In 3D Environments
Contents
• Concepts:– Geometry– Terminologies– (Time, Response, Performance, Robustness)
• Spatial Data Structures– Nonconvex Polyhedra (Convex Decomposition)– Space Partitioning (Voxel Grid, Quadtree, Octree, k-d Tree, BSP)– Model Partitioning (BVH)– Broad Phase Collision Detection (Sweep and Prune)
• Scene Management– Portals, PVS, Scene Graph, LOD
• Basic Primitives– Sphere: Sphere – Sphere, Ray – Sphere, Line segment – Sphere– AABB: Ray – Box, Sphere – Box– SAT (Separating Axis Test) : Line segment – Box, Triangle – Box, Box – Box– Polygons: Ray – Triangle, Line segment – Triangle, Ray – Polygon, Triangle – Triangle, Polygon – Polygon,
Triangle – Sphere, Polygon - Volume• Convex Objects
– Finding a Common Point– Finding a Separating Plane– GJK (Gilbert-Johnson-Keerthi) Distance Algorithm & Enhanced GJK– Lin-Canny Closest Feature Algorithm– Voronoi Clip Algorithm (V-Clip)
Ntreev Soft (in-house training) 4 Collision Detection In 3D Environments
Geometry
• Classical Geometry– Euclidean Geometry– Non-Euclidean Geometry– Affine Geometry
• Modern Geometry– Topology– Differential Geometry– Complex Projective Geometry– Finite Projective Geometry
• Reference: [KK88]
Ntreev Soft (in-house training) 5 Collision Detection In 3D Environments
Euclidean Geometry
• 유클레이데스 <원론 (Stoicheia)>
• 유클레이데스기하학에서의변환 f– 1대 1의점대응– 선분(또는직선)은선분(또는직선)에대응– 길이를바꾸지않는대응
• 즉, f 변환으로바뀌지않는성질이곧유클레이데스기하학의 ‘기하학적성질’ 이다.
Ntreev Soft (in-house training) 6 Collision Detection In 3D Environments
Affine Geometry
• F. Klein이 <Erlangen Programm>에서아핀변환에의해변하지않는기하학 의이론을 ‘아핀기하학’이라고명명.
• 아핀변환 f– 1대 1의점대응– 직선→직선
• 즉, 아핀변환 f 는평행투영에의한변환이며직선, 교점, 평행관계등은그대로 유지되나, 길이, 각의크기등의개념은무의미 (모든 3각형은같은도형)
Ntreev Soft (in-house training) 7 Collision Detection In 3D Environments
Non-Euclidean Geometry
• 19세기에이르러확립
• 유클레이데스의 <원론> ‘제5공준(=평행선공준)’– 『직선 a 위에없는한점 P를지나 a와만나지않는직선은오직한개만
그을수있다』
– 『P를지나 a와만나지않는직선을무수히그을수있다』고가정하여 도전혀모순이일어나지않는기하학이성립.
• 평행선의개수를이용한기하학분류– 직선바깥의한점을지나는평행선이
오직한개존재 : 유클레이데스기하학무수히존재 : 로바체프스키-보야이의비유클레이데스기하학하나도존재하지않음 : 리만의비유클레이데스기하학
Ntreev Soft (in-house training) 8 Collision Detection In 3D Environments
Projective Geometry (1)
• 대응(=寫像)에의해서도형의성질을다루는기하학
Ntreev Soft (in-house training) 9 Collision Detection In 3D Environments
Projective Geometry (2)
•
『Projective geometry is all geometry 』
사영기하학
비유클레이데스기하학 아핀기하학
유클레이데스기하학쌍곡선기하학 타원기하학
Ntreev Soft (in-house training) 10 Collision Detection In 3D Environments
Topology
• ‘위’(=위치, Lage)와 ‘상’(=형상, Gestalt)에관한 (정성적) 수학(기하학)
• 동상– C ≡
I ≡
J ≡
L ≡
M ≡
N ≡
S ≡
U ≡
V ≡
W ≡
Z,
– E ≡
F ≡
G ≡
T ≡
Y, H ≡
K, A ≡
R, D ≡
O, P, B, Q, X
• 동형
• 위상공간(=Topological space)– 위상적구조가주어진 (=집합의원소사이에 ‘근방’이정의되어진) 집합.
• 위상공간⊃거리공간⊃유클레이데스공간
• V – E + F = 2 (다면체), V – E + F = 0 (윤환면)
Ntreev Soft (in-house training) 11 Collision Detection In 3D Environments
Vector Space
• Let V be a set whose elements are called vectors.• Assume that equality of vectors is defined.• Suppose that there are two operations, vector addition (+) and scalar multiplication (•), such that
the following properties hold.
• 10 Axioms ( a, b, c ∈ R and v, u, w ∈ V )
1. ( closure under + ) u + v ∈ V2. ( + is associative ) u + (v + w) = (u + v) + w3. ( + is commutative ) u + v = v + u4. ( additive identity ) There is a vector 0 ∈ V such that v + 0 = v for any v ∈ V5. ( additive inverses ) for each v ∈ V there is a vector –v ∈ V such that v + (-v) = 06. ( closure under • ) c • v ∈ V, written simply as cv7. ( • is distributive over real addition ) (a + b)v = av + bv8. ( • is distributive over vector addition ) a(u + v) = au + av9. ( • is associative ) a(bv) = (ab)v10. ( multiplicative identity ) The number 1 ∈ R has the property 1•v = v
• The triple ( V, +, • ) is called a vector space over the real numbers.
Ntreev Soft (in-house training) 12 Collision Detection In 3D Environments
Computational Geometry
• Application Domain– Computer Graphics– Robotics– GIS (Geographic Information Systems)– CAD (Computer Aided Design) / CAM (Computer Aided Manufacturing)– Molecular modeling– Pattern recognition
• Reference: [BKOS00]
Ntreev Soft (in-house training) 13 Collision Detection In 3D Environments
Terminologies (1)
• Convex, Concave• BV (Bounding Volume)• Manifold & Non-Manifold
– Roughly, every edge has two faces joining it.• k-DOP ⊃ OBB ⊃ AABB• Half Space• SSV (Swept Sphere Volumes, S-topes)• Features
Convex Concave Manifold Non-Manifold
Ntreev Soft (in-house training) 14 Collision Detection In 3D Environments
Terminologies (2)
• Simplices– Points, Line segments, Triangles, Tetrahedra
• Polygons• Polyhedra• Convex quadrics
– Spheres, Cones, Capped cones, Cylinders, Capped cylinder, …• Convex objects
– Simplices, Convex polygons, Convex polyhedra, Convex quadrics, …• Polytopes
– Simplices ∪ Convex polygons ∪ Convex polyhedra• Polygon Soups
Ntreev Soft (in-house training) 15 Collision Detection In 3D Environments
Terminologies (3)
• CD (Collision Detection), PD (Penetration Depth)• Proximity Query
– A procedure to compute the geometric contact (and distance) between objects.
• Convex Hulls• Minkowski Addition / Difference• CSO (Configuration Space Obstacle)• Voronoi Diagrams, Voronoi Sites, Voronoi Regions• Frame Coherence, Geometric Coherence• Interval Halving• Ω-notation (asymptotic lower bound) & O-notation (asymptotic upper
bound)
Ntreev Soft (in-house training) 16 Collision Detection In 3D Environments
AABB and OBB
Ntreev Soft (in-house training) 17 Collision Detection In 3D Environments
k-DOP
• k-DOP (Discrete Orientation Polytope)• Set of k / 2 infinite slabs.• There is an even faster test if all objects have the same k and same
slab normals.• OBB and AABB are 6-DOP
Ntreev Soft (in-house training) 18 Collision Detection In 3D Environments
SSV
PSS LSS RSS
Ntreev Soft (in-house training) 19 Collision Detection In 3D Environments
Boundary Representations
• Winged Edge Structure – by Baumgart• DCEL (Doubly Connected Edge List) – by Muller and Preparata• Hierarchical Representation – by Dobkin and Kirkpatrick
Ntreev Soft (in-house training) 20 Collision Detection In 3D Environments
Convex Hulls (1)
• The smallest convex shape that contains a given collection of convex shapes[vdB04].
• The convex hull of a set of points S in n dimensions is the intersection of all convex sets containing S. For N points P1 , ..., PN , the convex hull C is then given by the expression[Mw].
Ntreev Soft (in-house training) 21 Collision Detection In 3D Environments
Convex Hulls (2)
• The incremental construction algorithm– Let PS be a set of n points in 3-space. CH(PS) is the convex hull of PS.– Choose four points in PS that do not lie in a common plane, so that their convex
hull is a tetrahedron.– Let PSr := p1 , …, pr .– If pr lies inside CH(PSr-1 ), or on its boundary, then CH(PSr ) = CH(PSr-1 )– Now suppose that pr lies outside CH(PSr-1 ). Imagine that you are standing at pr ,
and that you are looking at CH(PSr-1 ). You will be able to see some facets of CH(PSr-1 ). The visible facets form a connected region on the surface of CH(PSr-1 ), called the visible region of pr on CH(PSr-1 ), which is enclosed by a closed curve consisting of edges of CH(PSr-1). We call this curve the horizon of pr on CH(PSr-1). The horizon of pr forms the border between the part of the boundary that can be kept and the part of the boundary that must be replaced.
– Suppose that we knew all facets of CH(PSr-1 ) visible from pr . Then it would be easy to remove all the information stored for these facets from the DCEL, compute the new facets connecting pr to the horizon, and store the information for the new facets in the DCEL.
• Reference: [BKOS00]
Ntreev Soft (in-house training) 22 Collision Detection In 3D Environments
Minkowski Addition / Difference
• The convex shape that is the result of “adding” two convex shapes, that is, sweeping one shape along the point set of another.
• Minkowski Sum (The sum of sets A and B in a vector space)– A + B = a + b : a ∈ A, b ∈ B
• The negation operation– -B = -b : b ∈ B
Ntreev Soft (in-house training) 23 Collision Detection In 3D Environments
CSO
• Configuration Space Obstacle– A + (-B) = A – B
• The CSO contains all the information needed to answer a number of queries on pairs of objects in the context of collision detection.– A ∩
B ≠
Ø ≡
0 ∈ A – B
– The distance between two objects A and B, denoted by d(A,B), is defined as
d(A,B) = min a - b : a ∈ A, b ∈ B d(A,B) = min x : x ∈ A - B
– The penetration depth of a pair of intersecting objects, denoted by p(A,B), is the length of the shortest vector over which one of the objects needs to be translated in order to bring the pair in touching contact.
p(A,B) = inf x : x ∈ A – B (infimum: greatest lower bound)
Ntreev Soft (in-house training) 24 Collision Detection In 3D Environments
Voronoi Diagram
• The partitioning of a plane with n points into n convex polygons such that each polygon contains exactly one point and every point in a given polygon is closer to its central point than to any other[Mw].
Voronoi Site
Voronoi Region
Voronoi Diagram
Ntreev Soft (in-house training) 25 Collision Detection In 3D Environments
Coherences
• Frame Coherence– The measure of reusability of computations from earlier frames.
• Geometric Coherence– “Geometric coherence has to do with the degree to which a location in
space can be associated with one designated object, rather than the degree to which objects cohere.”
• Reference: [vdB04]
Ntreev Soft (in-house training) 26 Collision Detection In 3D Environments
Asymptotic Complexity
log n
nn log n (fastest sorting)n22n
n
Ntreev Soft (in-house training) 27 Collision Detection In 3D Environments
Spatial Data Structures
• Convex Decomposition (Nonconvex Polyhedra)– Joe’s Algorithm
• Space Partitioning (SP)– Voxel Grid– Quadtree– Octree– k-d Tree– BSP (Axis Aligned, Polygon Aligned)
• Model Partitioning– Bounding Volume Hierarchies (BVH)
• Broad Phase Collision Detection– Sweep and Prune
Ntreev Soft (in-house training) 28 Collision Detection In 3D Environments
Space Partitioning
• Algorithms:– Voxel Grid– Quadtree– Octree– k-d Tree– BSP (Axis Aligned, Polygon Aligned)
Voxel Grid Quadtree & Octree k-d Tree BSP
Ntreev Soft (in-house training) 29 Collision Detection In 3D Environments
Octree
Ntreev Soft (in-house training) 30 Collision Detection In 3D Environments
k-d Tree
1
2
3
4
5
67
8
9
10
11
12
13
14
15
8 9 10 11 12 13 14 15
4 5 6 7
2 3
1
Ntreev Soft (in-house training) 31 Collision Detection In 3D Environments
Bounding Volume Hierarchies (1)
• Bounding Volumes– OBB, AABB, k-DOP, Sphere, SSV, Convex hull, Ellipsoid, …
AABB OBBSphere Convex Hull6-DOP
Cost of (Overlap Tests + BV Update), Complexity, Tightness of Fit
Decreasing Increasing
Ntreev Soft (in-house training) 32 Collision Detection In 3D Environments
Bounding Volume Hierarchies (2)
• A binary bounding volume hierarchy
Ntreev Soft (in-house training) 33 Collision Detection In 3D Environments
Bounding Volume Hierarchies (3)
• Building an OBB Tree– Recursive top-down construction (Partition and Refit)
AB
C
D
EA
B C
D E
Ntreev Soft (in-house training) 34 Collision Detection In 3D Environments
Bounding Volume Hierarchies (4)
• Fitting OBBs
Ntreev Soft (in-house training) 35 Collision Detection In 3D Environments
Bounding Volume Hierarchies (5)
• Basic Hierarchy Traversal
Ntreev Soft (in-house training) 36 Collision Detection In 3D Environments
Bounding Volume Hierarchies (6)
• Dual Hierarchy Traversal
Ntreev Soft (in-house training) 37 Collision Detection In 3D Environments
Bounding Volume Hierarchies (7)
• AABB Trees vs OBB Trees (Approximation of a Torus)
Ntreev Soft (in-house training) 38 Collision Detection In 3D Environments
Bounding Volume Hierarchies (8)
• AABB Trees and Deformable Models
Ntreev Soft (in-house training) 39 Collision Detection In 3D Environments
SP vs BVH
BVH: Object centric, Spatial redundancy
SP: Space centric, Object redundancy
Ntreev Soft (in-house training) 40 Collision Detection In 3D Environments
Sweep and Prune (1)
• Compute the AABB (fixed vs dynamic) for each object.• Dimension reduction by projecting AABB onto each x, y, z – axis.• Sort the endpoints and find overlapping intervals.• Possible collision
– Only if projected intervals overlap in all 3 dimensions.• Sorting Methods
– Initial sort[Quick sort] runs in O(n log n) just as in any ordinary situation.
– Updating[Insertion sort] runs in O(n + k) due to coherence.
– We sort an almost sorted list from last stimulation step.– In fact, we look for “swap” of positions in all 3 dimension.
• Reference: [Bar92][vdB04]
Ntreev Soft (in-house training) 41 Collision Detection In 3D Environments
Sweep and Prune (2)
Ntreev Soft (in-house training) 42 Collision Detection In 3D Environments
Convex Objects
• Proximity Queries• Overview of Algorithms for Polytopes
– Finding a Common Point– Finding a Separating Plane– Distance and Penetration Depth Computation
• Simplex-based Algorithm– GJK Distance Algorithm & Enhanced GJK
Johnson’s Distance AlgorithmSupport MappingsPenetration Depth
• Feature-based Algorithm– Lin-Canny Closest Feature Algorithm– Voronoi Clip Algorithm
Ntreev Soft (in-house training) 43 Collision Detection In 3D Environments
Finding a Separating Plane (1)
• Separating Axis Theorem– Two polytopes A and B are disjoint iff there exists a separating axis
which is: perpendicular to a face from either or perpendicular to an edge from each.
• Implementations– Given two generic polytopes, the number of candidate axes to test
F1 + F2 + ( E1 * E2 )– OBBs have only E = 3 distinct edge directions, and only F = 3 distinct
face normals. OBBs need at most 15 axis tests. (2D: 4 axes to test)• Used in:
– Line segment ↔ Box– Triangle ↔ Box– OBB ↔ OBB– k-DOP ↔ k-DOP
Ntreev Soft (in-house training) 44 Collision Detection In 3D Environments
Finding a Separating Plane (2)
Polytope Polytope Number of axes to testLine segment Triangle 0 + 1 + ( 1 * 3 ) = 4Line segment Box 0 + 3 + ( 1 * 3 ) = 6Triangle Triangle 1 + 1 + ( 3 * 3 ) = 11Triangle Box 1 + 3 + ( 3 * 3 ) = 13Box Box 3 + 3 + ( 3 * 3 ) = 15
• The SAT works well for simple polytopes, such as line segments (rays), triangles, and boxes.
Ntreev Soft (in-house training) 45 Collision Detection In 3D Environments
GJK Distance Algorithm & Enhanced GJK
• Johnson’s Distance Algorithm• Support Mappings• Penetration Depth
Ntreev Soft (in-house training) 46 Collision Detection In 3D Environments
Voronoi Clip Algorithm (1)
• Voronoi Region• Basic Algorithm
– Given one feature from each polyhedron, find the nearest points of the two features.
– If each nearest point is in the Voronoi region of the other feature, closest features have been found.
– Else, walk to one or both of their neighbors or some other feature.• Running Time Analysis
– Distance strictly decreases with each change of feature pair, and no pair of features can be selected twice.
– Convergence to closest pair typically much better for dynamic environments.
O(1) achievable in simulations with coherence.Closer to sub-linear time performance even without coherence.
Ntreev Soft (in-house training) 47 Collision Detection In 3D Environments
Voronoi Clip Algorithm (2)
Face
Edge 1 Edge 2
Edge 3Vert 1
Vert 2
Vert 3
Ntreev Soft (in-house training) 48 Collision Detection In 3D Environments
Voronoi Clip Algorithm (3)
• Closest Feature Tracking Using Voronoi Regions
Ntreev Soft (in-house training) 49 Collision Detection In 3D Environments
Appendix: Collision Cases
• Vertex, Edge, Face 6 cases
Ntreev Soft (in-house training) 50 Collision Detection In 3D Environments
Appendix: The Elements of Simulator
Broad Phase Collision Detection
Narrow Phase Collision Detection
Contact Determination
Contact Analysis
Collision Solver
Time Control
Motion Solver
Constraint Solver
Mass Property Analysis
Ntreev Soft (in-house training) 51 Collision Detection In 3D Environments
Appendix: System Architecture of Simulator
Analysis & Response
Broad PhaseCollision Detection
Simulation
Collision
Transform Overlap
Parameters
Narrow PhaseCollision Detection
Ntreev Soft (in-house training) 52 Collision Detection In 3D Environments
Appendix: Public Domain Packages (1)
• Collision Detection / Proximity Query Packages – SOLID
GJKOBB tree
– OPCODECollision library for triangle meshes.AABB tree
– RAPIDPart of V-COLLIDEOBB tree
– CULLIDEInteractive Collision Detection Between Complex Models in Large Environments using Graphics HardwarePotentially Colliding Set (PCS)
– V-COLLIDEMore general than I-COLLIDEThe system uses OBB tree as defined in RAPID but uses temporal coherence to speed up
– I-COLLIDELin-Canny AlgorithmN-body overlap tests (sweep and prune).
Distance calculation between convex polytopes.– SWIFT
Variant of the LC feature-walking algorithmMore powerful than I-COLLIDESpeedy Walking via Improved Feature Testing
– SWIFT++An evolution of SWIFTSupports nonconvex polyhedra
Ntreev Soft (in-house training) 53 Collision Detection In 3D Environments
Appendix: Public Domain Packages (2)
• Collision Detection / Proximity Query Packages – DEEP
Dual-space Expansion for Estimating Penetration depth between convex polytopes– H-COLLIDE– PIVOT
Proximity Information from VOronoi TechniquesThe system uses graphics hardware acceleration to support the queries
– PQPProximity Query PackageThe system SSV and supports overlap testing, distance computation, and tolerance verificationGood for any proximity queryReleased in July’99Strong interest from Sony
– IMMAPCTInteractive Massive Model Proximity And Collision TestingBuilt on top of PQPUse of METIS
– Q-COLLIDEA non-UNCA variation of I-COLLIDE and V-COLLIDEThe system uses separating Axes to determine intersections rather than tracking closest features but still uses spatial and temporal coherence
• Tools– QHull
Convex Hull Generation
Ntreev Soft (in-house training) 54 Collision Detection In 3D Environments
Appendix: Demos
Ntreev Soft (in-house training) 55 Collision Detection In 3D Environments
Bibliography
• [Bar92] David Baraff. Dynamic Simulation of Non-Penetrating Rigid Bodies. PhD thesis, Computer Science Department,Cornell University, 1992. Technical Report 92-1275.
• [BKOS00] M. de Berg, M. van Kreveld, M. Overmars and O. Schwarzkopf. Computational Geometry 2nd Edition. Springer, 2000.• [KK88] 김용운, 김용국. 토폴로지入門. 祐成文化社, 1988.• [Mir98] Brian Mirtich. V-Clip: Fast and robust polyhedral collision detection. ACM Transactions on Graphics, 1998.• [Mw] http://mathworld.wolfram.com• [vdB04] Gino van den Bergen. Collision Detection in Interactive 3D Environments. Morgan Kaufmann Publishers, 2004.• [Wis03] CS679 - Fall 2003 - Copyright Univ. of Wisconsin.
Ntreev Soft (in-house training) 56 Collision Detection In 3D Environments
People
• Ming C. Lin• Brian Mirtich• Gino van den Bergen• David H. Eberly
Ntreev Soft (in-house training) 57 Collision Detection In 3D Environments
Note
Top Related