Computational Geometry & Collision detection

Slides:



Advertisements
Similar presentations
2.5. B ASIC P RIMITIVE I NTERSECTION Details of common forms of primitive intersection test.
Advertisements

ADA: 15. Basic Math1 Objective o a reminder about dot product and cross product, and their use for analyzing line segments (e.g. do two segments.
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/
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
CS 450: Computer Graphics OVERVIEW OF POLYGONS
Sasha Vasserman.  Two triangles are similar if two pairs of corresponding angles are congruent.
12 VECTORS AND THE GEOMETRY OF SPACE.
Chapter 4.1 Mathematical Concepts
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.
CSCE 590E Spring 2007 Basic Math By Jijun Tang. Applied Trigonometry Trigonometric functions  Defined using right triangle  x y h.
OBBTree: A Hierarchical Structure for Rapid Interference Detection Gottschalk, M. C. Lin and D. ManochaM. C. LinD. Manocha Department of Computer Science,
1Notes. 2 Time integration for particles  Back to the ODE problem, either  Accuracy, stability, and ease-of- implementation are main issues  Obviously.
Vectors.
Linear Algebra Review CSE169: Computer Animation Instructor: Steve Rotenberg UCSD, Winter 2005.
Chapter 3: VECTORS 3-2 Vectors and Scalars 3-2 Vectors and Scalars
Geometry Chapter 20. Geometry is the study of shapes Geometry is a way of thinking about and seeing the world. Geometry is evident in nature, art and.
Geometric Objects and Transformations Geometric Entities Representation vs. Reference System Geometric ADT (Abstract Data Types)
CSE554SimplificationSlide 1 CSE 554 Lecture 7: Simplification Fall 2014.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
©A. Weinberg By Ms. Weinberg SOL ©A. Weinberg Let’s learn a bit about Geometry! Geometry is a part of Math that focuses on shapes and lines. Shapes.
Chapter 3. Vector 1. Adding Vectors Geometrically
Week 13 - Wednesday CS361.
12/4/2001CS 638, Fall 2001 Today Using separating planes/axes for collision testing Collision detection packages.
CHS Physics Multiplying Vectors. Three Possibilities 1. Multiplying a Vector by a Scalar 2. Multiplying Vector by a Vector 1. Scalar Product 2. Vector.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
UNIVERSITI MALAYSIA PERLIS
Functions of several variables. Function, Domain and Range.
CS 450: Computer Graphics REVIEW: OVERVIEW OF POLYGONS
Section 13.4 The Cross Product. Torque Torque is a measure of how much a force acting on an object causes that object to rotate –The object rotates around.
Mathematics for Graphics. 1 Objectives Introduce the elements of geometry  Scalars  Vectors  Points Develop mathematical operations among them in a.
CS 325 Introduction to Computer Graphics 02 / 17 / 2010 Instructor: Michael Eckmann.
Properties of Vector Operations: u, v, w are vectors. a, b are scalars. 0 is the zero vector. 0 is a scalar zero. 1. u + v = v + u 2. (u + v) + w = u +
Computer Animation Rick Parent Computer Animation Algorithms and Techniques Collisions & Contact.
Week 13 - Monday.  What did we talk about last time?  Exam 2!  Before that…  Polygonal techniques ▪ Tessellation and triangulation  Triangle strips,
Quaternions Paul Taylor Swizzle What is a swizzle?
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
CSE554SimplificationSlide 1 CSE 554 Lecture 7: Simplification Fall 2013.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
Background Mathematics Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006.
Advanced Computer Graphics Spring 2014 K. H. Ko School of Mechatronics Gwangju Institute of Science and Technology.
Geometry Review By: Kyle Dykes. Chapter 1 Important Terms – Line: extends in one dimension- – Collinear Points: Points that lie on the same line – Coplanar.
Copyright © Cengage Learning. All rights reserved. 12 Vectors and the Geometry of Space.
Copyright © Cengage Learning. All rights reserved.
3D Game Engine Design 1 3D Game Engine Design Ch D MAP LAB.
An introduction to 3D Figures
1 11. Polygons Polygons 2D polygons ( 다각형 ) –Polygon sides are all straight lines lying in the same plane 3D polyhedra ( 다면체 )  chap. 12 –Polyhedra.
Vectors and the Geometry
VECTORS AND THE GEOMETRY OF SPACE. The Cross Product In this section, we will learn about: Cross products of vectors and their applications. VECTORS AND.
Chapter 8 Engineering Geometry
VECTORS AND THE GEOMETRY OF SPACE 10. VECTORS AND THE GEOMETRY OF SPACE In this chapter, we introduce vectors and coordinate systems for three-dimensional.
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⁰.
CS 376 Introduction to Computer Graphics 02 / 14 / 2007 Instructor: Michael Eckmann.
Chapter 8 Geometry Part 1. 1.Introduction 2.Classifying Angles 3.Angle Relationships 4.Classifying Triangles 5.Calculating Missing Angles Day…..
3D Ojbects: Transformations and Modeling. Matrix Operations Matrices have dimensions: Vectors can be thought of as matrices: v=[2,3,4,1] is a 1x4 matrix.
Math Fundamentals Maths revisit.
Engineering Geometry Engineering geometry is the basic geometric elements and forms used in engineering design. Engineering and technical graphics are.
CSC461: Lecture 12 Geometry Objectives
Lecture 03: Linear Algebra
Vectors and the Geometry
Vectors & Equilibrium Sara sultan 07/04/2019.
Computer Animation Algorithms and Techniques
CO Games Concepts Week 12 Collision Detection
Game Programming Algorithms and Techniques
GPAT – Chapter 7 Physics.
Presentation transcript:

Computational Geometry & Collision detection Vectors, Dot Product, Cross Product, Basic Collision Detection George Georgiev Telerik Corporation www.telerik.com

Table of Contents Vectors The vector dot product Extended revision The vector dot product The vector cross product Collision detection In Game programming Sphere collision Bounding volumes AABBs

Revision, Normals, Projections Vectors Revision, Normals, Projections

A Vectors – revision Ordered sequences of numbers OA (6, 10, 18) – 3-dimensional OA (6, 10) – 2-dimensional OA (6, 10, 18, -5) – 4-dimensional Have magnitude and direction A

Vectors – revision No location Can represent points in space Wherever you need them Can represent points in space Points are vectors with a beginning at the coordinate system center Example: Point A(5, 10) describes the location (5, 10) Vector U(5, 10), beginning at (0, 0), describes ‘the path’ to the location (5, 10)

Vectors – revision All vectors on the same line are called collinear Can be derived by scaling any vector on the line E.g.: A(2, 1), B(3, 1.5), C(-1, -0.5) are collinear Two vectors, which are not collinear, lie on a plane and are called coplanar => Two non-collinear vectors define a plane Three vectors, which are not coplanar, define a space

Vectors – revision Collinear vectors: Coplanar vectors:

Vectors – revision Vectors defining a 3D vector space

Vectors – revision Perpendicular vectors Constitute a right angle Deriving a vector, perpendicular to a given one: Swap two of the coordinates of the given vector (one of the swapped coordinates can’t be zero) Multiply ONE of the swapped coordinates by -1 Example: A (5, 10) given => A’(-10, 5) is perpendicular to A V (3, 4, -1) given => V’(3, 1, 4) is perpendicular to V

Vectors – revision Normal vectors to a surface Constitute a right angle with flat surfaces Perpendicular to at least two non-collinear vectors on the plane Constitute a right angle with the tangent to curved surfaces

Vectors – revision Projection of a vector on another vector

Definition, Application, Importance Vector Dot Product Definition, Application, Importance

Vector dot product Dot Product (a.k.a. scalar product) Take two equal-length sequences e.g. sequence A (5, 6) and sequence B (-3, 2) Multiply each element of A with each element of B A [i] * B [i] Add the products Dot Product(A, B) = A[0] * B[0] + A[1] * B[1] + … + A[i] * B[i] + … + A[n-1] * B[n-1]

Vector dot product Dot Product (2) Example: Result A (5, 6) B (-3, 2) = 5 * (-3) + 6 * 2 = -15 + 12 = -3 Result A scalar number

Vector dot product Dot product of coordinate vectors Take two vectors of equal dimensions Apply the dot product to their coordinates 2D Example: A(1, 2) . B(-1, 1) = 1*(-1) + 2*1 = 1 3D Example: A(1, 2, -1) . B(-1, 1, 5) = 1*(-1) + 2*1 + (-1) * 5 = -4 Simple as that

Vector dot product Meaning in Euclidean geometry If A(x1, y1, …), B(x2, y2, …) are vectors theta is the angle, in radians, between A and B Dot Product (A, B) = A . B = = |A|*|B|*cos(theta) Applies to all dimensions (1D, 2D, 3D, 4D, … nD)

Vector dot product Meaning in Euclidean geometry (2) If U and V are unit vectors, then U . V = cosine of the angle between U and V the oriented length of the projection of U on V If U and V are non-unit vectors ( U . V ) divided by |U|*|V| = cosine of the angle between U and V ( U . V ) divided by |V| = the oriented length of the projection of U on V

Vector dot product Consequences Applications If A . B > 0, A and B are in the same half-space If A . B = 0, A and B are perpendicular If A . B < 0, A and B are in different half-spaces Applications Calculating angles Calculating projections Calculating lights Etc…

Dot Product Computation * Dot Product Computation Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Definition, Features, Application Vector Cross Product Definition, Features, Application

Vector cross product Cross product Operates on vectors with up to 3 dimensions Forms a determinant of a matrix of the vectors Result – depends on the dimension In 2D – a scalar number (1D) In 3D – a vector (3D) Not defined for 1D and dimensions higher than 3

2D Vector cross product 2D Cross product Take the vectors U(x1, y1) and V(x2, y2) Multiply their coordinates across and subtract: U(x1, y1) x V(x2, y2) = (x1 * y2) – (x2 * y1) Result A scalar number

2D Vector cross product Scalar meaning in Euclidean geometry If U(x1, y1) and V(x2, y2) are 2D vectors theta is the angle between U and V Cross Product (U, V) = U x V = = |U| * |V| * sin(theta) |U| and |V| denote the length of U and V Applies to 2D and 3D

2D Vector cross product Scalar meaning in Euclidean geometry (2) For every two 2D vectors U and V U x V = the oriented face of the parallelogram, defined by U and V For every three 2D points A, B and C If U x V = 0, then A, B and C are collinear If U x V > 0, then A, B and C constitute a ‘left turn’ If U x V < 0, then A, B and C constitute a ‘right turn’

2D Vector cross product Applications Graham scan (2D convex hull) Easy polygon area computation Cross product divided by two equals oriented (signed) triangle area 2D orientation ‘left’ and ‘right’ turns

2D Cross Product Computation * 2D Cross Product Computation Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

3D Vector cross product 3D Cross product Take two 3D vectors U(x1, y1, z1) and V(x2, y2, z2) Calculate the following 3 coordinates x3 = y1*z2 – y2*z1 y3 = z1*x2 – z2*x1 z3 = x1*y2 – x2*y1 Result A 3D vector with coordinates (x3, y3, z3)

3D Vector cross product Meaning in Euclidean geometry The magnitude Always positive (length of the vector) Has the unsigned properties of the 2D dot product The vector Perpendicular to the initial vectors U and V Normal to the plane defined by U and V Direction determined by the right-hand rule

3D Vector cross product The right-hand rule Index finger points in direction of first vector (a) Middle finger points in direction of second vector (b) Thumb points up in direction of the result of a x b

3D Vector cross product Unpredictable results occur with Applications Cross product of two collinear vectors Cross product with a zero-vector Applications Calculating normals to surfaces Calculating torque (physics)

3D Cross Product Computation * 3D Cross Product Computation Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Computational geometry ? ? ? ? ? Questions? ? ? ? ? ? ?

Basics, Methods, Problems, Optimization Collision detection Basics, Methods, Problems, Optimization

Collision detection Collisions in Game programming Any intersection of two objects’ geometry Raise events in some form Usually the main part in games Collision response – deals with collision events

Collision detection Collision objects Can raise collision events Types Spheres Cylinders Boxes Cones Height fields Triangle meshes

Collision detection Sphere-sphere collision Easiest to detect Used in particle systems low-accuracy collision detection Collision occurrence: Center-center distance less than sum of radiuses Optimization Avoid computation of square root

Sphere-sphere collision detection * Sphere-sphere collision detection Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Collision detection Triangle meshes collision Very accurate Programmatically heavy Computation heavy (n2) Rarely needed

Collision detection Collision detection in Game programming Combines several collision models Uses bounding volumes Uses optimizations Axis-sweep Lower accuracy in favor of speed

Collision detection Bounding volumes Easy to check for collisions Spheres Boxes Cylinders, etc. Contain high-triangle-count meshes Tested for collision before the contained objects If the bounding volume doesn’t collide, then the mesh doesn’t collide

Collision detection Bounding sphere Orientation-independent Center – mesh’s center Radius distance from mesh center to farthest vertex Effective for convex, oval bodies mesh center equally distant from surface vertices rotating bodies

Bounding sphere generation * Bounding sphere generation Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Collision detection Minimum bounding sphere Center – the center of the segment, connecting the two farthest mesh vertices Radius – the half-length of the segment, connecting the two farthest mesh vertices Efficient with convex, oval bodies rotating bodies Sphere center rotated with the other mesh vertices

Minimum bounding sphere generation * Minimum bounding sphere generation Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Collision detection Axis-aligned bounding box (AABB) Very fast to check for collisions Usually smaller volume than bounding spheres Edges parallel to coordinate axes Minimum corner coordinates – lowest coordinate ends of mesh Maximum corner coordinates – highest coordinate ends of mesh

Collision detection Axis-aligned bounding box (2) Efficient with non-rotating bodies convex bodies oblong bodies If the body rotates, the AABB needs to be recomputed

Axis-aligned bounding box generation * Axis-aligned bounding box generation Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Collision detection Checking AABBs for collision Treat the minimum and maximum corners’ coordinates as interval edges 3D case If the x intervals overlap And the y intervals overlap And the z intervals overlap Then the AABBs intersect / collide

Axis-aligned bounding box collision detection * Axis-aligned bounding box collision detection Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Collision detection Oriented bounding box (OBB) Generated as AABB Rotates along with the object’s geometry Advantage: Rotating it is much faster than creating an new AABB Usually less volume than AABB Disadvantage: Much slower collision check

Oriented bounding box updating * Oriented bounding box updating Live Demo (c) 2008 National Academy for Software Development - http://academy.devbg.org. All rights reserved. Unauthorized copying or re-distribution is strictly prohibited.*

Computational geometry & Collision detection ? ? ? ? ? Questions? ? ? ? ? ? ?