CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.

Slides:



Advertisements
Similar presentations
This terms course Last term we both worked on learning 2 things –Processing –The concepts of graphics etc. This term will focus more on the basic concepts.
Advertisements

Introduction Finding the distance between two points on a coordinate system is similar to finding the distance between two points on a number line. It.
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
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/
APPLICATIONS OF INTEGRATION
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
2.1. C OLLISION D ETECTION Overview. Collision detection is used within many types of application, e.g. from robotics, through engineering simulations,
Computational Geometry & Collision detection
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.
Chapter 4.2 Collision Detection and Resolution. 2 Collision Detection Complicated for two reasons 1. Geometry is typically very complex, potentially requiring.
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.
Collision Detection Michael Fuller. Overlap testing Most Common Technique Most Error Prone Test if two bodies overlap.
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
Mr Barton’s Maths Notes
GCSE Mathematics 4 th of June 2015 (non-calculator) 8 th of June 2015 (calculator) Adding fractions You can’t add them together until the bottoms (denominators)
Introduction Finding the distance between two points on a coordinate system is similar to finding the distance between two points on a number line. It.
Geometry
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
1 CO Games Development 1 Week 5 Deriving a "look at" function + Graph Theory Gareth Bellaby.
UNIVERSITI MALAYSIA PERLIS
COMP 175: Computer Graphics March 24, 2015
By: De’Aja Koontz 6 Th Period.  A member of the set of positive whole numbers {1, 2, 3,... }, negative whole numbers {-1, -2, -3,... }, and zero {0}.
October 14, 2014Computer Vision Lecture 11: Image Segmentation I 1Contours How should we represent contours? A good contour representation should meet.
Introduction This chapter reminds us of how to calculate midpoints and distances between co-ordinates We will see lots of Algebraic versions as well We.
CSE 381 – Advanced Game Programming Quickhull and GJK.
CSE 381 – Advanced Game Programming GJK. GJK Gilbert – Johnson – Keerthi distance algorithm Used to determine the minimum distance between convex sets.
1 CO Games Development 1 Week 6 Introduction To Pathfinding + Crash and Turn + Breadth-first Search Gareth Bellaby.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CS 325 Introduction to Computer Graphics 04 / 26 / 2010 Instructor: Michael Eckmann.
1 of 66 KS4 Mathematics S6 Transformations. 2 of 66 A A A A A A Contents S6.1 Symmetry S6 Transformations S6.2 Reflection S6.3 Rotation S6.4 Translation.
1 CO Games Concepts Week 20 Matrices continued Gareth Bellaby.
AUTHOR GCSE LINEAR EXAM QUESTIONS (FOUNDATION)
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
PYTHAGORAS Aim: To be able to know Pythagoras’ Theorem All: Will be able to recall theorem. Most: Will be able to use to find the length of hypotenuse.
CGDD 4003 THE MATH LECTURE (BOILED DOWN, YET LIGHTLY SALTED)
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Chapter 1: Square Roots and the Pythagorean Theorem Unit Review.
1. The sum of two nonnegative numbers is 20. Find the numbers
Maths & Technologies for Games Spatial Partitioning 2
Artificial Intelligence in Game Design Lecture 8: Complex Steering Behaviors and Combining Behaviors.
If you draw squares on the two shorter sides…
CSCE 552 Fall 2012 Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
Geometry Vocabulary. Triangle Triangle: a polygon with three sides. 180⁰ Sum of the interior angles of a triangle = 180⁰.
1 CO Games Development 1 Week 4 Finite State Machines + Maths Gareth Bellaby.
 G K Powers 2013 Cambridge University Press 8. Applications of perimeter, area and volume Study guide 1.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Game Programming 13 Physics in Games (cont.) 2010 년 2 학기 디지털콘텐츠전공.
SKETCHING LINEAR GRAPHS (3A). THE METHODS  There are many methods for sketching linear graphs:  plotting  x and y intercept method  gradient intercept.
Chapter 8 Geometry Part 1. 1.Introduction 2.Classifying Angles 3.Angle Relationships 4.Classifying Triangles 5.Calculating Missing Angles Day…..
Standard Grade Prelim Revision The topics we will be revising are: 1. Wednesday 17 th November – Pythagoras 2. Monday 22 nd November – Statistics 3. Tuesday.
Maths in Biosciences – Strategic sampling. Find the infected ash tree Column vector Coordinate Ash dieback DiseaseFungus epidemic.
Perimeter, area and volume
CO1301: Games ts 2015 Lecture 6 Vectors Dr Nick Mitchell (Room CM 224)
Intro & Point-to-Box, Circle-to-Circle, Point-to-Circle
In this section, we will learn about: Using integration to find out
Trigonometry 1. Pythagoras
Mathematics Volume.
Chapter 4.2 Collision Detection and Resolution
CO1301: Games Concepts Lecture 13 Basic Trigonometry
07/12/2018 Starter L.O. To be able to Solve a quadratic by factorising
KS4 Mathematics A6 Quadratic equations.
CO Games Concepts Week 12 Collision Detection
PYTHAGORAS.
Presentation transcript:

CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby Lecture 5 Using Vectors for Collision Detection

Reading about Vectors  Rabin, Introduction to Game Development:  4.2: "Collision Detection and Resolution"  Van Verthe, Essential Mathematics for Games:  14.6: "A Simple Collision System"

Lecture Outline Vector practice (Revision) Collision detection and resolution

Topic 1:A reminder about Vectors

Right-angled triangles  Remember that with a right-angled triangle the length of the longest side (called the hypotenuse) is equal to the square root of the sum of the squares of two shorter sides. (Pythagoras’ Theorem)

Vector between two points  The vector V going from point P1 to point P2 is P1 subtracted from P2 (i.e. P2 – P1)  Remember that P1, P2 and V are all expressed as Cartesian co-ordinates.  The vector V from P1 to P2 is: = V( X 2 - X 1, Y 2 - Y 1, Z 2 - Z 1 )

Length of a vector  A vector makes a right-angled triangle in 3 dimensions... ...so use Pythagoras’ Theorem about right-angle triangles to calculate the length of the vector.  If we have a vector V(X, Y, Z) then:

Normalised vector  A normal is any vector whose length is 1.  It is also caled the direction vector.  A vector is converted to a normal (i.e. normalised) by dividing the components by the length:

Topic 2:Collision Detection

Collision Detection  Collision detection is a common operation.  You often need to able to determine whether two objects in a game have come into contact:  A bullet hitting a target  A racing car reaching the winning point  The player-character trying to move through a wall  Checking whether an event has triggered, e.g. a triggered piece of dialogue or a monster jumping out.  Distance calculations also come under this topic.

Point to Point Collsions  The objects move frame by frame. Calculate the distance between the two points each frame.

Point to Point  Point to point is the simplest case.  Example: a bullet striking a bull's eye.  Point to point is simply a matter of working out the distance between two points. This is the same calculation as the length of a vector.

Bounding volumes  Most objects in a game are not points so you cannot use point to point calculations.  It is time consuming and mathematically complex to test whether two complex objects intersect.  Instead use a simplified shape that fits around the object – a bounding volume.

Bounding volumes  Complex objects:  Bounding spheres:

Bounding volumes  Make the bounding volume as close a fit as possible.  Spheres and boxes are two commonly used shapes.  The technique sacrifices precision for efficiency (speed) – an issue which crops up frequently in games programming...  Bounding volumes are also used for a initial coarse check before engaging in more fine detailed analysis,  e.g. a bounding sphere can be employed to see whether there is any chance of collision.

Point to Sphere collisions  Check to see whether a point has collided with a sphere.  The radius of a sphere is the distance from the centre of the sphere to the edge of the sphere.  Calculate the distance from the point to the centre of the sphere.  If the distance is smaller than the radius of the sphere then a collision has occurred.

Point to Sphere

Sphere to Sphere Collisions  Surround both object with close fitting spheres.  The radius of a sphere is the distance from the centre of the sphere to its edge.  Calculate the distance from the centre of the first sphere to the centre of the second sphere.  If the distance is smaller than the sum of the sphere radii then a collision has occurred.

Sphere to Sphere

More bounding volumes  Spheres are useful because the maths is comparatively simple - it's just an extension of vector calculations.  Spheres also suit some objects, e.g. people (you would probably use a cylinder in practice... ...but 2 dimensionally, a sphere (i.e. a circle) is equivalent to a cylinder (with zero height).  But spheres do not suit all objects, e.g. a crate or a house.  In these cases a box (cuboid) would be a more appropriate approximation.

Bounding boxes  The simplest box is an "axis-aligned bounding box”.  The box is exactly aligned with the axes, e.g. horizontally and vertically.

Bounding boxes  A box which is not axis-aligned will be more difficult to use.  However, some objects fit better inside a box than a sphere.  A problem arises if the object can rotate. Boxes better suit objects that cannot rotate.  Of course, it is possible to do the calculations for a non-axis aligned bounding box. However, I am going to leave this until we move on to planes and point to plane collisions...

Point to Axis-Aligned Box  Check the position of the point against the minimum and maximum x, y and z values of the box.

Sphere to Box Collision  The easiest way to implement this is to do a bit of sideways thinking...  The sphere collides with the box when its edge crosses over the edge of the box.  This can only happen if the distance from the centre of the sphere to the edge of the box is smaller than the radius of the sphere.  So lets expand the size of the bounding box by the radius of the sphere.  Now do a simple point to box calculation instead.

Sphere to Box  Same method as point to box, but add the radius to the maximum x, y and z values of the box, and subtract it from the minimum x, y and z values. Note that this method is inaccurate at the corners...

Collision Resolution  The order of operation is always:  Collision Detection  Collision Resolution  Need to have a resolution because:  An object moves over the course of one frame to the next  If an object collides with an obstacle and we do not attempt to resolve the collision immediately...  The object could become stuck because it may well be inside the obstacle.

Collision Resolution  Moving frame- by-frame...  Therefore the object is inside the obstacle when the collision is detected...  Hence it will become stuck inside the object.

Simple Collision Resolution Algorithm  Move the model.  Record the movement vector you used to move the model (x, y, z).  Check if a collision has occurred.  If a collision has occurred:  Move the model back to where it was at the beginning of the frame (-x, -y, -z)  Note that this is simplistic.  You should check to see where along the path of movement the collision occurred and set the position to this location  You will look at the maths to do it at a later time.