Presentation is loading. Please wait.

Presentation is loading. Please wait.

Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.

Similar presentations


Presentation on theme: "Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron."— Presentation transcript:

1 Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron

2 Lines and Rays Given 2 points, we can parametrically define a line which passes through these two points as  P(t) = (1-t)P 1 + tP 2 The line segment between these two points corresponds to all values of t between zero and one A ray is defined parametrically as  P(t) = P o + tV Where t is greater than or equal to zero  Allowing negative values of t will give a valid equation for a line

3 Planes Plane equation  Ax + By + Cz + D = 0 A, B, and C are the respective x, y, and z coordinates of a vector normal to the plane D = -N.P o  N is the plane normal vector  P o is an arbitrary point on the plane If N is a unit vector, the equation  d = N.Q + D Gives the distance from the plane to an arbitrary point Q If d > 0, Q lies on the positive side of the plane. Otherwise Q lies on the negative side of the plane.  Use this to test for path-plane collision

4 A Different Plane Equation Point – normal form  N.(P – P o ) = 0 P and P o are arbitrary points on the plane  Stored as a point and a normal in many applications, or calculated on the fly from three points. Given by equation  N.Q + D = 0  Line – Plane intersection Example

5 Spheres Sphere equation  (x - x 0 ) 2 + (y - y 0 ) 2 + (z - z 0 ) 2 = r 2  r is the radius, and is centered at (x 0,y 0,z 0 ) In an application, store the center point and the radius.

6 Frustums A frustum as a volume of space containing everything visible in a scene. A frustum can be defined by a:  Near plane (or near plane distance)  Far plane (or far plane distance)  Field of view FOV x or FOV y ?  Aspect ratio Alternatively, it can be described by the six planes which bound it.

7 Frustum Illus.

8 Triangle

9 Polygon

10 Polyhedron Convex polyhedrons are also known as polytopes, and are often used to approximate non-convex meshes where speed is an issue. Also known as brushes.

11 Applied Geometry Collision models for games can be approximated using fundamental shapes  E.g. Use boxes for limbs of characters, 3 spheres for an ant…

12 Visibility Determination *Bounding box test Bounding sphere test

13 Bounding Box Axis aligned, or AABB  Find minimum and maximum points and use these to construct box Oriented, or OBB  Find natural axes for points  Compute dot product of each vertex position with unit vectors R, S, T of the natural axis and take the minimum and maximum values Planes are given by:

14 Collision Detection Sphere – Sphere Sphere - Plane *AABB – AABB *OBB – OBB *Box – Plane Ray – Plane Ray – Triangle

15 Ray – Triangle Intersection Example Investigate other methods  Badoul’s algorithm  Moller-Haines’ algorithm  D3DX algorithm D3DX common source

16 Usage / Examples Detecting when a user has clicked an object Determining if, when, and where objects have collided  Decide how to respond to collision

17 Reading Chapters 4, 5, 7, 8 in Mathematics for 3D Game Programming and Computer Graphics cover the material presented here


Download ppt "Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron."

Similar presentations


Ads by Google