Skip to Main Content
3D Game Engine Design, 2nd Edition
book

3D Game Engine Design, 2nd Edition

by David Eberly
November 2006
Intermediate to advanced content levelIntermediate to advanced
1040 pages
26h 31m
English
CRC Press
Content preview from 3D Game Engine Design, 2nd Edition
8.3 A Dynamic Collision Detection System 469
lists. For general input it is O(n
2
), but for nearly sorted data it is O(n + e),where
e is the number of exchanges used by the algorithm. Pseudocode for the insertion
sort is
// input: A[0] through A[n-1]
// output: array sorted in-place
void InsertionSort (int n, type A[])
{
for(j=1;j<n;j++)
{
key = A[j];
i=j-1;
while(i>=0andA[i] > key )
{
Swap(A[i],A[i+1]);
i--;
}
A[i+1] = key;
}
}
The situation so far is that we have applied the sort-and-sweep algorithm to
our collection of intervals, a once-only step that requires O(n log n + m) time. The
output is a set S of pairs (i, j)that correspond to overlapping intervals, I
i
I
j
.Some
intervals are now moved, and the list of endpoints is re-sorted in O(n + e) time. The
set S
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

3D Game Engine Architecture

3D Game Engine Architecture

David Eberly
Blender 3D By Example - Second Edition

Blender 3D By Example - Second Edition

Oscar Baechler, Xury Greer
Computer Graphics

Computer Graphics

Alexey Boreskov, Evgeniy Shikin

Publisher Resources

ISBN: 9781482267303