190 likes | 329 Views
CS6360 Collision Detection/Response Loose End. David Johnson. Work Through An Example. Two objects Rectangle and Triangle. (-1,2) (1,2) (0,1). (-1, -2) (1,-2) (-1,-1) (1,-1). Compute Center of Mass. Find the area using signed area of polyline face
E N D
CS6360 Collision Detection/Response Loose End David Johnson
Work Through An Example • Two objects • Rectangle and Triangle (-1,2) (1,2) (0,1) (-1, -2) (1,-2) (-1,-1) (1,-1)
Compute Center of Mass • Find the area using signed area of polyline face • Nth vertex same as 0th • Compute centroid coordinates
Translate the Triangle (-1,2) (1,2) (3,1) (-1, -2) (1,-2) (2,-1) (4,-1)
Check for Collision • Use GJK • Pick a random direction to start the simplex (1,1) • Find the support vertex of Minkowski difference Z support(Z, d) = support(Y, d) – support(X, -d)
Support for the Box Support(Y,d) = (1,2) (-1,2) (1,2) (-1, -2) (1,-2)
Support for the Triangle support(X, -d) = (2,-1) (3,1) (2,-1) (4,-1)
Total Support • support(Z, d) = support(Y, d) – support(X, -d) = (1,2) – (2,-1) = (-1,3) • Increase the simplex by finding new dir
Find new support Support(Z,d) = (1,-2) – (3,1) = (-2,-3) (-1,2) (1,2) (3,1) (2,-1) (4,-1) (-1, -2) (1,-2)
Extend Simplex • Simplex is now a line • Find closest point • Make new dir (-1.45, 0.24)
Find new support Support(Z,d) = (1,-2) – (2,-1) = (-1,3) (-1,2) (1,2) (3,1) (2,-1) (4,-1) (-1, -2) (1,-2)
Simplex Doesn’t Extend • Closest Point has same distance as last time • No collision (-1.45, 0.24)
Look at Collision Case Support(Z,d) = (-1,2) – (2.5,-1) = (-3.5,3) (-1,2) (1,2) (1.5,1) (0.5,-1) (2.5,-1) (-1, -2) (1,-2)
Initialize Simplex • Simplex is a point • Find closest point • Make new dir
Look at Collision Case Support(Z,d) = (1,-2) – (1.5, 1) = (-0.5,-3) (-1,2) (1,2) (1.5,1) (0.5,-1) (2.5,-1) (-1, -2) (1,-2)
Extend Simplex • Simplex is a line • Find closest point • Make new dir
Look at Collision Case Support(Z,d) = (1,2) – (0.5, -1) = (0.5,-3) (-1,2) (1,2) (1.5,1) (0.5,-1) (2.5,-1) (-1, -2) (1,-2)
Extend Simplex • Simplex is a line • Find closest point • Make new dir
What is the Collision Normal? (-1,2) (1,2) (1.5,1) (0.5,-1) (2.5,-1) (-1, -2) (1,-2)