CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.

Slides:



Advertisements
Similar presentations
Real-Time Game Physics
Advertisements

Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
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/
Chapter 4.3 Real-time Game Physics. Outline Introduction Motivation for including physics in games Practical development team decisions Particle Physics.
Rotational Equilibrium and Rotational Dynamics
Introduction to Statics
Rotational Equilibrium and Rotational Dynamics
Chapter 11 Angular Momentum.
Chapter 4.1 Mathematical Concepts
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
Chapter 4.1 Mathematical Concepts. 2 Applied Trigonometry Trigonometric functions Defined using right triangle  x y h.
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.
UNC Chapel Hill S. Redon - M. C. Lin Rigid body dynamics II Solving the dynamics problems.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Game Mathematics & Game State The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object Overlap.
CSCE 590E Spring 2007 Collision Detection By Jijun Tang.
Manipulator Dynamics Amirkabir University of Technology Computer Engineering & Information Technology Department.
Introduction What is this ? What is this ? This project is a part of a scientific research in machine learning, whose objective is to develop a system,
CSCE 590E Spring 2007 Basic Physics By Jijun Tang.
Mechanics, Dynamics & Aesthetics The Complexity of Games Expectations of Players Efficiency Game Mathematics o Collision Detection & Response o Object.
Collision Detection Michael Fuller. Overlap testing Most Common Technique Most Error Prone Test if two bodies overlap.
CIS 487/587 Bruce R. Maxim UM-Dearborn
CS 4730 Collision Detection CS 4730 – Computer Game Design.
CS 4730 Physical Simulation CS 4730 – Computer Game Design.
FE Exam: Dynamics review
Newton’s Third Law of Motion
Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Dynamics. Chapter 1 Introduction to Dynamics What is Dynamics? Dynamics is the study of systems in which the motion of the object is changing (accelerating)
FE Exam: Dynamics review D. A. Lyn School of Civil Engineering 21 February 2012.
CSCE 552 Spring 2009 Math, Physics and Collision Detection By Jijun Tang.
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Math / Physics 101 GAM 376 Robin Burke Fall 2006.
AP Physics C: Mechanics Chapter 11
Computer Game Design and Development Mathematics, Collision, and Physics Havok Destruction.
6.2 Gravitational field and gravitational field strength
Force and Motion This week – This week – Force and Motion – Chapter 4 Force and Motion – Chapter 4.
Advanced Computer Graphics Rigid Body Simulation Spring 2002 Professor Brogan.
CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang.
Dynamics: Newton’s Laws of Motion
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Physics for Games Spring 2012.
Introduction to Particle Simulations Daniel Playne.
Chapter 11 Angular Momentum. Angular momentum plays a key role in rotational dynamics. There is a principle of conservation of angular momentum.  In.
Computer Game Design and Development
Bridges To Computing General Information: This document was created for use in the "Bridges to Computing" project of Brooklyn College. You are invited.
Chapter 5 The Laws of Motion.
CS274 Spring 01 Lecture 7 Copyright © Mark Meyer Lecture VII Rigid Body Dynamics CS274: Computer Animation and Simulation.
Dynamics: Newton’s Laws of Motion. Force A force is a push or pull. An object at rest needs a force to get it moving; a moving object needs a force to.
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Advanced Games Development Game Physics CO2301 Games Development 1 Week 19.
Chapter 4 Dynamics: Newton’s Laws of Motion. Units of Chapter 4 Force Newton’s First Law of Motion Mass Newton’s Second Law of Motion Newton’s Third Law.
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
Introduction to Game Programming & Design III Lecture III.
Advanced Computer Graphics Rigid Body Simulation
Introduction.
Done already for your convenience!
Dynamics: Newton’s Laws of Motion
CE 102 Statics Chapter 1 Introduction.
Introduction.
Math, Physics and Collision Detection
Chapter 4.2 Collision Detection and Resolution
Introduction.
Introduction.
Mechanics, Dynamics & Aesthetics
Introduction.
Motion in Real and Virtual Worlds
Computer Animation Algorithms and Techniques
Dynamics: Newton’s Laws of Motion
Introduction.
GPAT – Chapter 7 Physics.
Presentation transcript:

CSCE 552 Fall 2012 Math, Physics and Collision Detection By Jijun Tang

Homework #2 Major use cases of your system Due on Wednesday Oct 17 th, before class.

Use Cases Use Case Name: Place Order Actors:  Registered Shopper (Has an existing account, possibly with billing and shipping information)  Fulfillment System (processes orders for delivery to customers)  Billing System (bills customers for orders that have been placed) Triggers:  The user indicates that she wants to purchase items that she has selected. Preconditions:  User has selected the items to be purchased. Post-conditions:  The order will be placed in the system.  The user will have a tracking ID for the order.  The user will know the estimated delivery date for the order. Flow:  The user will indicate that she wants to order the items that have already been selected.  The system will present the billing and shipping information that the user previously stored.  The user will confirm that the existing billing and shipping information should be used for this order.  The system will present the amount that the order will cost, including applicable taxes and shipping charges.  The user will confirm that the order information is accurate.  The system will provide the user with a tracking ID for the order.  The system will submit the order to the fulfillment system for evaluation.  The fulfillment system will provide the system with an estimated delivery date.  The system will present the estimated delivery date to the user.  The user will indicate that the order should be placed.  The system will request that the billing system should charge the user for the order.  The billing system will confirm that the charge has been placed for the order.  The system will submit the order to the fulfillment system for processing.  The fulfillment system will confirm that the order is being processed.  The system will indicate to the user that the user has been charged for the order.  The system will indicate to the user that the order has been placed.  The user will exit the system.

2D Example θ

Translation A 3  3 matrix can reorient the coordinate axes in any way, but it leaves the origin fixed We must add a translation component D to move the origin:

Homogeneous coordinates Four-dimensional space Combines 3  3 matrix and translation into one 4  4 matrix

Translation Translation matrix Translates the origin by the vector T

Scale Scale matrix Scales coordinate axes by a, b, and c If a = b = c, the scale is uniform

Rotation (Z) Rotation matrix Rotates points about the z-axis through the angle 

Rotations (X, Y) Similar matrices for rotations about x, y

Geometry -- Lines 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 corresponds to a value of the parameter t Two lines are parallel if their direction vectors are parallel

Plane A plane in 3D space can be defined by a normal direction N and a point P Other points in the plane satisfy P Q N

Distance from Point to a Line Distance d from a point P to a line S + t V P VS d

Line and Plane Intersection Let P(t) = S + t V be the line Let L = (N, D) be the plane We want to find t such that L  P(t) = 0 Careful, S has w-coordinate of 1, and V has w-coordinate of 0

Formular If L  V = 0, the line is parallel to the plane and no intersection occurs Otherwise, the point of intersection is

Real-time Physics in Game at Runtime: Enables the emergent behavior that provides player a richer game experience Potential to provide full cost savings to developer/publisher Difficult  May require significant upgrade of game engine  May require significant update of asset creation pipelines  May require special training for modelers, animators, and level designers Licensing an existing engine may significantly increase third party middleware costs

Engines Commercial  Game Dynamics SDK (Havok.com)  Renderware Physics (renderware.com)  NovodeX SDK (novodex.com) Free  Open Dynamic Engine (ODE) (ode.org)  Tokamak Game Physics SDK (tokamakphysics.com)  Newton Game Dynamics SDK (newtondynamics.com)  Unity

Particle Physics What is a Particle?  A sphere of finite radius with a perfectly smooth, frictionless surface  Experiences no rotational motion (or assume the sphere has no size) Particle Kinematics  Defines the basic properties of particle motion  Position, Velocity, Acceleration

Location of Particle in World Space  SI Units: meters (m)  Changes over time when object moves Particle Position

Particle Velocity and Acceleration Velocity (SI units: m/s)  First time derivative of position: Acceleration (SI units: m/s 2 )  First time derivative of velocity  Second time derivative of position

Newton ’ s 2 nd Law of Motion Paraphrased – “ An object ’ s change in velocity is proportional to an applied force ” The Classic Equation:  m = mass (SI units: kilograms, kg)  F(t) = force (SI units: Newtons)

What is Physics Simulation? The Cycle of Motion:  Force, F(t), causes acceleration  Acceleration, a(t), causes a change in velocity  Velocity, V(t) causes a change in position Physics Simulation: Solving variations of the above equations over time to emulate the cycle of motion

Concrete Example: Target Practice Target Projectile Launch Position, p init

Choose V init to Hit a Stationary Target  p target is the stationary target location  We would like to choose the initial velocity, V init, required to hit the target at some future time, t hit.  Here is our equation of motion at time t hit : Target Practice

Equation Problem Solution in general is a bit tedious to derive … Infinite number of solutions! Hint: Specify the magnitude of V init, solve for its direction

Example 1 V init = 25 m/s Value of Radicand of tan  equation: Launch angle  : 19.4 deg or 70.6 deg

Finite Difference Methods-I The Explicit Euler Integrator: Properties of object are stored in a state vector, S Use the above integrator equation to incrementally update S over time as game progresses Must keep track of prior value of S in order to compute the new For Explicit Euler, one choice of state and state derivative for particle:

Finite Difference Methods-II The Verlet Integrator: Must store state at two prior time steps, S(t) and S(t-  t) Uses second derivative of state instead of the first Valid for constant time step only (as shown above) For Verlet, choice of state and state derivative for a particle:

Errors Exact Euler

Generalized Rigid Bodies Key Differences from Particles  Not necessarily spherical in shape  Position, p, represents object ’ s center-of-mass location  Surface may not be perfectly smooth and friction forces may be present  Experience rotational motion in addition to translational (position only) motion

Additional forces Linear Spring Viscous Damping Aerodynamic Drag Friction …

Linear Springs

Viscous Damping

Aerodynamic Drag S: projected front area C D : drag coefficient

Friction

Collision Detection and Resolution

What is Collision Detection A fundamental problem in computer games, computer animation, physically-based modeling, geometric modeling, and robotics. Including algorithms:  To check for collision, i.e. intersection, of two given objects  To calculate trajectories, impact times and impact points in a physical simulation.

Collision Detection Complicated for two reasons  Geometry is typically very complex, potentially requiring expensive testing  Naïve solution is O(n 2 ) time complexity, since every object can potentially collide with every other object Two basic techniques  Overlap testing: Detects whether a collision has already occurred  Intersection testing: Predicts whether a collision will occur in the future

Overlap Testing (a posteriori) Overlap testing: Detects whether a collision has already occurred, sometime is referred as a posteriori Facts  Most common technique used in games  Exhibits more error than intersection testing Concept  For every (small) simulation step, test every pair of objects to see if they overlap  Easy for simple volumes like spheres, harder for polygonal models

Overlap Testing Results Useful results of detected collision  Pairs of objects will have collision  Time of collision to take place  Collision normal vector Collision time calculated by moving object back in time  until right before collision  Bisection is an effective technique

Bisect Testing: collision detected

Bisect Testing: Iteration I

Bisect Testing: Iteration II

Bisect Testing: Iteration III

Bisect Testing: Iteration IV

Bisect Testing: Iteration V Time right before the collision

Overlap Testing: Limitations Fails with objects that move too fast  Thin glass vs. bulltes  Unlikely to catch time slice during overlap

Solution for This Limitation Speed of the fastest object multiplies the time step should be smaller than the smallest objects in the scene Possible solutions  Design constraint on speed of objects: hard to apply without affecting the play  Reduce simulation step size: too expensive

Intersection Testing (a priori) Predict future collisions When predicted:  Move simulation to time of collision  Resolve collision  Simulate remaining time step

Intersection Testing: Swept Geometry Extrude geometry in direction of movement Swept sphere turns into a “ capsule ” shape

Intersection Testing: Sphere-Sphere Collision d

Special Cases No collision: B 2 = 0: both objects are stationary, or they are traveling at parallel When will collision occur?

Intersection Testing: When to Collide Smallest distance ever separating two spheres: If there is a collision

Intersection Testing: Limitations Issue with networked games  Future predictions rely on exact state of world at present time  Due to packet latency, current state not always coherent Assumes constant velocity and zero acceleration over simulation step  Has implications for physics model and choice of integrator

Dealing with Complexity Two issues 1. Complex geometry must be simplified 2. Reduce number of object pair tests

Simplified Geometry Approximate complex objects with simpler geometry, like this ellipsoid or bounding boxes

Minkowski Sum By taking the Minkowski Sum of two complex volumes and creating a new volume, overlap can be found by testing if a single point is within the new volume

Minkowski Sum

Using Minkowski Sum

Bounding Volumes Bounding volume is a simple geometric shape  Completely encapsulates object  If no collision with bounding volume, no more testing is required Common bounding volumes  Sphere  Box

Box Bounding Volumes

More Examples

Using Bounding Box in Game Complex objects can have multiple bounding boxes  Human object can have one big bounding box for the whole body  Human object can have one bounding box per limb, head, etc Bounding box can be hierarchical:  Test the big first  if possible collision, test the smaller ones

Reduce Number of Detections O(n) Time Complexity can be achieved. One solution is to partition space

Achieving O(n) Time Complexity Another solution is the plane sweep algorithm Requires (re-)sorting in x (y) coordinate