3.3: Rectangle Collisions

Slides:



Advertisements
Similar presentations
VC Dimension – definition and impossibility result
Advertisements

2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Incremental Linear Programming Linear programming involves finding a solution to the constraints, one that maximizes the given linear function of variables.
Theory of Computing Lecture 18 MAS 714 Hartmut Klauck.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Collision Detection and Resolution Zhi Yuan Course: Introduction to Game Development 11/28/
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Extended Gaussian Images
I. The Problem of Molding Does a given object have a mold from which it can be removed? object not removable mold 1 object removable Assumptions The object.
Chapter 10 Constructions.
Incidences and Many Faces via cuttings Sivanne Goldfarb
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
A Fast Algorithm for Incremental Distance Calculation Paper by Ming C. Ling and John F. Canny Presented by Denise Jones.
Intersections. Intersection Problem 3 Intersection Detection: Given two geometric objects, do they intersect? Intersection detection (test) is frequently.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Basic 3D collision detection We want to know if objects have touched Objects are considered to.
3. Delaunay triangulation
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Geometry A line in 3D space is represented by  S is a point on the line, and V is the direction along which the line runs  Any point P on the line.
Efficient Distance Computation between Non-Convex Objects by Sean Quinlan presented by Teresa Miller CS 326 – Motion Planning Class.
Computer graphics & visualization Collision Detection – Narrow Phase.
9-4 Geometry in Three Dimensions  Simple Closed Surfaces  Regular Polyhedra  Cylinders and Cones.
Week 13 - Wednesday CS361.
Data Structures Week 9 Towards Weighted BFS So, far we have measured d s (v) in terms of number of edges in the path from s to v. Equivalent to assuming.
Collision handling: detection and response
RA PRESENTATION Sublinear Geometric Algorithms B 張譽馨 B 汪牧君 B 李元翔.
3.4. C ONTACT G ENERATION Generating contacts between rigid bodies.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Computational Geometry Piyush Kumar (Lecture 10: Point Location) Welcome to CIS5930.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Implementation II.
Computer Graphics I, Fall 2010 Implementation II.
3D Design Precision Measurement Creating Holes Types of Edges The Offset Tool Copy and Paste Roof Types.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
A Fast Algorithm for Incremental Distance Calculation Ming C. Lin and John F. Canny University of California, Berkeley 1991 Original slides by Adit Koolwal.
A Fast Algorithm for Incremental Distance Calculation Ming C. Lin & John Canny University of California, Berkeley 1991 Presentation by Adit Koolwal.
9/26/2016HL Math - Santowski1 Lesson 49 – Working with Definite Integrals HL Math- Santowski.
3. Polygon Triangulation
2D Simulation of Rigid Bodies
Computer Graphics Implementation II
Name the polygon by the number of sides.
Theme: Hockey By: Shane Hughes 7th Hour 1/4/2012
Constructing Objects in Computer Graphics By Andries van Dam©
GG 450 February 19, 2008 Magnetic Anomalies.
Localizing the Delaunay Triangulation and its Parallel Implementation
The Art Gallery Problem
Craig Schroeder October 26, 2004
Lesson 46 – Working with Definite Integrals
The Art Gallery Problem
Depth Estimation via Sampling
Implementation II Ed Angel Professor Emeritus of Computer Science
Convex Sets & Concave Sets
2.5. Basic Primitive Intersection
I. The Problem of Molding
CURVED MIRRORS.
On the Geodesic Centers of Polygonal Domains
Coordinate Systems.
Computer Animation Algorithms and Techniques
Introduction to Computer Graphics with WebGL
The Theory of NP-Completeness
Transformations for GCSE Maths
CO Games Concepts Week 12 Collision Detection
Implementation II Ed Angel Professor Emeritus of Computer Science
Orthographic Projection
Volume and Surface Area
Separating Axis Theorem (SAT)
Presentation transcript:

3.3: Rectangle Collisions Chapter 3 3.3: Rectangle Collisions

3.3 Collision between non-aligned Rectangles Broad-phase Circle bound collision EASY Axis-aligned Bbox Bound interersection Now …

Separating Axis Theorem (SAT)

SAT in English Given two convex polygons, Iterate through each edge of the two polygones Extend the edge to infinity If the extended edge separates the vertices of the two polygons then, the two polygons do not intersect If none of the edges satisfies the above, then, collision has occurred Able to exit early if find the edge early in the iteration

SAT Implementation Implementation Strength Given two polygons (ANY convex-gons) Collided = true //  assume this is true For each edge (of each gon) Compute a line that is perpendicular to the edge Project all other edges onto this line If the projected edges do not overlap Collided = false; // The two gons DO NOT collide! Strength For non-colliding shapes: early termination Can terminate as soon as we find the first edge with no overlaps in projection

Apply SAT Apply SAT for the following edges What can you conclude?

Apply SAT

Apply SAT Projected edges overlap No conclusion can be made

Apply SAT

Apply SAT Projected edges DO NOT overlap! No intersection between the two rectangles!

Apply SAT again Apply SAT for the following edges What can you conclude?

Apply SAT Look at this face

Apply SAT Edge/face normal

Apply SAT

Apply SAT

Apply SAT Overlap! Conclusion? NOTHING!

Apply SAT Apply SAT for the following edges What can you conclude?

Apply SAT Let’s look at this edge

Apply SAT Edge/Face normal

Apply SAT

Apply SAT Again, no conclusion

What about now?

What about now? Still, no conclusion

What about now? BUT, if we look at this edge

What about now? Face normal

What about now? Project

What about now? Project Conclusion?

SAT … Iterate through ALL face normal Define a line Project all edges onto the line If no overlaps in the projected segements  Conclusion: no collision Early termination! If reach the end Collision

SAT Implementation: Step 1 Compute edge normal (or face normal)

SAT Implementation: Step 2 Project vertices

SAT Implementation: Step 3 Establish bounds

SAT Implementation: Step 4 Determine overlaps

Problem with simple SAT implementation Only capable of giving yes/no answer! We need to compute CollisionInfo Normal, Depth, Start/End points To resolve interpenetration!

Examine this again Project to ALL axis

How to resolve overlap?

How to resolve overlap? Pay attention to the overlaps

How to resolve overlap?

“push out” (along Axis direction)

Can we resolve based on other edges/axes?

Can we resolve based on other edges/axes?

Interesting? Does not quite work? Notice that … Always push “the other” Resolved polygon no longer collided with the edge! But pushed too far! Two observations: First. Per-edge operation!! Resolve in the direction of the axis

Resolve the collision based on SAT results For the red edge

Resolve the collision based on SAT results

Resolve the collision based on SAT results

Resolve the collision based on SAT results

Implementation Idea For each edge of this polygon One of observation Compute distances of vertices from the other polygon to this edge The farthest distance, is the one we must push One of observation

Implementation Idea For each edge of this polygon One of observation Compute distances of vertices from the other polygon to this edge The farthest distance, is the one we must push One of observation Only care about overlaps So, distance is negative (behind the edge)

Support Point: Efficient SAT Implementation Given two convex polygons: A and B Support Point For an edge on A (will use the edge normal) [faceNormal] For each Vertex on B Vertex-i on B is a support point for an edge-e on A when Vertex-i has the MOST NEGATIVE distance from edge-e Distance measured along the face normal of edge-e Associated distance: support point distance Note: Support point relationship changes for each frame!!

Find all the support points

Find all the support points Edge-e on A Vertex-i on B Distance measured along face normal of Edge-e Edge-e and face normal

Find all the support points Edge-e on A Vertex-i on B Distance measured along face normal of Edge-e Edge and face normal Vertex-i

Find all the support points Edge-e on A Vertex-i on B Distance measured along face normal of Edge-e Edge and face normal Vertex-i Distance measured along face normal (negative number)

Support point? Edge-e on A Vertex-i on B Edge and face normal Vertex-i Distance measured along face normal of Edge-e Edge and face normal Vertex-i Distance measured along face normal (negative number)

Support point? Edge-e on A Vertex-i on B Edge and face normal Distance measured along face normal of Edge-e Support point is the MOST negative! Edge and face normal Vertex-i Distance measured along face normal (negative number)

What about this edge? Edge-e on A Vertex-i on B Edge-e and face normal Distance measured along face normal of Edge-e Support point is the MOST negative! Edge-e and face normal

What about this edge? Edge-e on A Vertex-i on B Edge-e and face normal Distance measured along face normal of Edge-e Support point is the MOST negative! Edge-e and face normal

What about this edge? Edge-e on A Vertex-i on B Edge-e and face normal Distance measured along face normal of Edge-e Support point is the MOST negative! This distance is positive?! Edge-e and face normal

What about this edge? Edge-e on A Vertex-i on B Edge-e and face normal Distance measured along face normal of Edge-e Support point is the MOST negative! This distance is positive?! Edge-e and face normal

Find all the support points

No Support Point: Vertex-i on B is a support point for an edge-e on A when Vertex-i has the MOST NEGATIVE distance from edge-e Distance measured along the normal of edge-e For edge eB1: no support point Because A is entirely in front of B  No support points: DO NOT collide Early termination! As soon as we find an edge without support points Implementation note: Support Distance: measured along negative normal direction

Axis of least penetration If all support points are defined for all edges of both polygons Axis of least penetration The face normal of the smallest support point distance

SAT Implementation with Support Point

Axis of least penetration

SAT Implementation: FindSupportPoint

SAT Implementation: FindSupportPoint Input: negative Face normal of other Input: a vertex on the edge This: rectangle -dir

SAT Implementation: FindSupportPoint This: rectangle dir ptOnEdge vToEdge

SAT Implementation: FindSupportPoint projection ptOnEdge vToEdge

SAT Implementation: Axis of Least Penetration

SAT Implementation: Axis of Least Penetration

SAT Implementation: Axis of Least Penetration

SAT Implementation: Axis of Least Penetration otherRect

SAT Implementation: everything together

SAT Implementation: everything together r2 has support points for every edge or r1

SAT Implementation: everything together For each edge of r1, r2 has a corresponding support point For each edge of r2, r1 has a corresponding support point

SAT Implementation: everything together For each edge of r1, r2 has a corresponding support point For each edge of r2, r1 has a corresponding support point Choose one with smaller collision depth