Raycasting polygonal models

Similar documents
Number Sense and Operations

The Dot and Cross Products

Figure 1.1 Vector A and Vector F

BALTIC OLYMPIAD IN INFORMATICS Stockholm, April 18-22, 2009 Page 1 of?? ENG rectangle. Rectangle

Geometry Chapter Point (pt) 1.1 Coplanar (1.1) 1.1 Space (1.1) 1.2 Line Segment (seg) 1.2 Measure of a Segment

Algebra Academic Content Standards Grade Eight and Grade Nine Ohio. Grade Eight. Number, Number Sense and Operations Standard

Pre-Algebra Academic Content Standards Grade Eight Ohio. Number, Number Sense and Operations Standard. Number and Number Systems

Cabri Geometry Application User Guide

Common Core Unit Summary Grades 6 to 8

Higher Education Math Placement

521493S Computer Graphics. Exercise 2 & course schedule change

MATHS LEVEL DESCRIPTORS

Geometry and Measurement

FURTHER VECTORS (MEI)

Equations Involving Lines and Planes Standard equations for lines in space

Lesson 29: Lenses. Double Concave. Double Convex. Planoconcave. Planoconvex. Convex meniscus. Concave meniscus

CHAPTER 8, GEOMETRY. 4. A circular cylinder has a circumference of 33 in. Use 22 as the approximate value of π and find the radius of this cylinder.

Mathematics. Mathematical Practices

1 of 9 2/9/2010 3:38 PM

Adding vectors We can do arithmetic with vectors. We ll start with vector addition and related operations. Suppose you have two vectors

6. Vectors Scott Surgent (surgent@asu.edu)

Answer: The relationship cannot be determined.


Chapter 8 Geometry We will discuss following concepts in this chapter.

Algebra Geometry Glossary. 90 angle

Assessment Anchors and Eligible Content

Angle - a figure formed by two rays or two line segments with a common endpoint called the vertex of the angle; angles are measured in degrees

Convex Mirrors. Ray Diagram for Convex Mirror

of surface, , , of triangle, 548 Associative Property of addition, 12, 331 of multiplication, 18, 433

WORK SCHEDULE: MATHEMATICS 2007

5.3 The Cross Product in R 3

SAT Subject Math Level 1 Facts & Formulas

Charlesworth School Year Group Maths Targets

Relevant Reading for this Lecture... Pages

Copyright 2011 Casa Software Ltd. Centre of Mass

Grade 6 Mathematics Performance Level Descriptors

TWO-DIMENSIONAL TRANSFORMATION

MODERN APPLICATIONS OF PYTHAGORAS S THEOREM

Solving Simultaneous Equations and Matrices

L 2 : x = s + 1, y = s, z = 4s Suppose that C has coordinates (x, y, z). Then from the vector equality AC = BD, one has

Reflection and Refraction

Section 1.1. Introduction to R n

Quick Reference ebook

11.1. Objectives. Component Form of a Vector. Component Form of a Vector. Component Form of a Vector. Vectors and the Geometry of Space

THREE DIMENSIONAL GEOMETRY

MATH STUDENT BOOK. 8th Grade Unit 6

Vector Math Computer Graphics Scott D. Anderson

Geometry Notes PERIMETER AND AREA

Illinois State Standards Alignments Grades Three through Eleven

Largest Fixed-Aspect, Axis-Aligned Rectangle

Additional Topics in Math

Section 9.1 Vectors in Two Dimensions

Everyday Mathematics. Grade 4 Grade-Level Goals CCSS EDITION. Content Strand: Number and Numeration. Program Goal Content Thread Grade-Level Goal

Shape Dictionary YR to Y6

Everyday Mathematics CCSS EDITION CCSS EDITION. Content Strand: Number and Numeration

4. How many integers between 2004 and 4002 are perfect squares?

Math 241, Exam 1 Information.

Everyday Mathematics. Grade 4 Grade-Level Goals. 3rd Edition. Content Strand: Number and Numeration. Program Goal Content Thread Grade-Level Goals

Everyday Mathematics GOALS

Solving Geometric Problems with the Rotating Calipers *

28 CHAPTER 1. VECTORS AND THE GEOMETRY OF SPACE. v x. u y v z u z v y u y u z. v y v z

1. A student followed the given steps below to complete a construction. Which type of construction is best represented by the steps given above?

Computational Geometry. Lecture 1: Introduction and Convex Hulls

GeoGebra. 10 lessons. Gerrit Stols

Analysis of Stresses and Strains

INTRODUCTION TO RENDERING TECHNIQUES

Biggar High School Mathematics Department. National 5 Learning Intentions & Success Criteria: Assessing My Progress

Glencoe. correlated to SOUTH CAROLINA MATH CURRICULUM STANDARDS GRADE 6 3-3, , , 4-9

Class One: Degree Sequences

Measurement with Ratios

CHAPTER 1. LINES AND PLANES IN SPACE

Selected practice exam solutions (part 5, item 2) (MAT 360)

Geometry Course Summary Department: Math. Semester 1

The Force Table Introduction: Theory:

13.4 THE CROSS PRODUCT

Shortest Path Algorithms

Intermediate Math Circles October 10, 2012 Geometry I: Angles

Intersection of Convex Objects: The Method of Separating Axes

Name Class. Date Section. Test Form A Chapter 11. Chapter 11 Test Bank 155

Math 0980 Chapter Objectives. Chapter 1: Introduction to Algebra: The Integers.

Current Standard: Mathematical Concepts and Applications Shape, Space, and Measurement- Primary

Final Review Geometry A Fall Semester

When the fluid velocity is zero, called the hydrostatic condition, the pressure variation is due only to the weight of the fluid.

Geometric Optics Converging Lenses and Mirrors Physics Lab IV

Determine whether the following lines intersect, are parallel, or skew. L 1 : x = 6t y = 1 + 9t z = 3t. x = 1 + 2s y = 4 3s z = s

Arrangements And Duality

2. Spin Chemistry and the Vector Model

The Essentials of CAGD

Expression. Variable Equation Polynomial Monomial Add. Area. Volume Surface Space Length Width. Probability. Chance Random Likely Possibility Odds

Numeracy Targets. I can count at least 20 objects

Three-Dimensional Figures or Space Figures. Rectangular Prism Cylinder Cone Sphere. Two-Dimensional Figures or Plane Figures

AP Physics - Vector Algrebra Tutorial

Session 7 Bivariate Data and Analysis

ME 111: Engineering Drawing

Exam 1 Sample Question SOLUTIONS. y = 2x

Lesson 18: Looking More Carefully at Parallel Lines

SOLIDS, NETS, AND CROSS SECTIONS

CHAPTER FIVE. 5. Equations of Lines in R 3

Big Ideas in Mathematics

2. If C is the midpoint of AB and B is the midpoint of AE, can you say that the measure of AC is 1/4 the measure of AE?

Transcription:

Chapter 9 Raycasting polygonal models A polygonal model is one in which the geometry is defined by a set of polygons, each specified by the D coordinates of their vertices. For example, the cube to the right is specified by its eight vertices, v...v 7. With the vertex coordinates given, we see that the cube is centered at the origin, aligned so its sides are parallel to the x-y, y-z, and z-x planes, and each face is a x square. If we want to raycast such a model, we need two things:. a way to determine ray polygon intersections, and. a way to determine a surface normal at each intersection. v 5 (-,, -) (,, -) v (-,, ) (,, ) v (-, -, -) (, -, -) v (-, -, ) (, -, ) v v v 6 v 7 5

5 9. CHAPTER 9. RAYCASTING POLYGONAL MODELS About polygons We start the consideration of ray polygon intersection with the definition of a polygon (we will consider only simple polygons). Definition: a polygon is an ordered set of vertices, all lying in a single plane, such that edges connecting the vertices, in order, form a closed loop with no edges crossing. Some example polygons are shown to the right. These are all convex polygons, since the internal angles formed by connecting edges at each vertex are all less than 8. To the right are some more polygons. Note, that even Pac Man is a polygon! These are both concave polygons, since at leaset one pair of vertex edges connect to form an internal angle greater than 8. 5 6 7 7 whacka......whacka 6 8 5 The star and diamond shown to the right are not polygons according to our definition. The star has crossing edges and the diamond consists of two disconnected loops, with one forming a hole in the other. We could expand our definition of a polygon to include these sorts of figures. In fact, they are often called complex polygons. But, for our purposes we will not include them for now. 7 5 6 Finally, this is not a polygon at all, since vertex does not lie in the same plane as vertices,, and. Since a polygon is by definition planar, we can determine the plane the polygon lies in by using any two non-parallel edges to compute the v v n v v

9.. RAY-POLYGON INTERSECTION 55 normal to the plane, n = (v v ) (v v ) (v v ) (v v ), and any vertex to complete the plane definition, for example p = v. So, the distance of any point x from the plane of the polygon is d = (x p) n, (9.) and the plane equation is (x p) n =. (9.) 9. Ray-polygon intersection We can intersect a ray with a polygon in steps:. find the ray-plane intersection x hit, and. determine whether or not x hit falls inside or outside of the polygon. For ray-plane intersection we just replace x in Equation 9. by the ray equation x = p r + tu r and solve for t: t hit = (p p r) n. u r n If t hit < then there is no ray-plane intersection. If t hit < then there is an intersection at x hit = p r + t hit u r. Determining if x hit is inside or outside of the polygon will tell us if we have a ray polygon intersection or not. Note that the problem is planar, since all the vertices of the polygon and x hit lie in the same plane. With this in mind, a way to make the inside outside test is this. If we shoot a ray lying in the plane from a point inside the polygon it will always intersect an odd number of edges (,, 5,...). If we shoot a ray from outside the polygon it will always intersect an even number of edges (,,,...). u r p r x hit

56 CHAPTER 9. RAYCASTING POLYGONAL MODELS Here are some pictures showing this: So here is an algorithm:. Make the problem D by projecting all points into a coordinate plane (like the x-y plane for example).. Translate all points so that x hit is at the origin.. Let the positive x axis be the ray.. Count the number of edges that cross the positive x axis. If this number is odd, then the point lies inside the polygon, if even, then outside. And, here are some details of how this could be implemented: Y x hit. Projection: Z Find the coordinate plane that has the largest parallel projection (image) of the polygon into the plane and project to that plane by discarding the coordinate orthogonal to the plane: to the x-y plane (x, y, z) = (x, y), to the y-z plane (x, y, z) = (y, z), to the z-x plane (x, y, z) = (z, x). The surface normal to the plane of the polygon will tell you which plane to project to. Think about how this would be done.

9.. A SPECIAL CASE: RAY-TRIANGLE INTERSECTION 57 Y. Translation: Simply subtract xhit from each of the xhit projected D vertices.. Use the positive x axis for the ray.. Count the crossings with the positive x axis. Think about how to organize this counting to do the minimum number of calculations. Note: you do not necessarily have to calculate where the positive x axis crosses an edge. You only need to know whether or not it crosses the edge. 9. A special case: ray-triangle intersection Note that a triangle is always a polygon. Three ordered vertices always lie in a single plane, no edges can cross, and there can be no holes. For this reason, graphics systems use triangles, wherever possible, to represent polygonal surfaces, especially when it comes time to render them. All of the desirable properties of a triangle turn out to be extremely important to writing an efficient and correct rendering algorithm. For many calculations over triangles, a metric representation called barycentric coordinates is very convenient. Barycentric coordinates provide a measuring system that positions a point relative to the edges of the triangle, with a very simple scheme for converting from regular D spatial coordinates to barycentric coordinates, and from barycentric to D spatial coordinates.

58 CHAPTER 9. RAYCASTING POLYGONAL MODELS Baycentric coordinates define a position with respect to the positions of the vertices of a triangle. Considering the diagram to the right, the point x is internal to the triangle p, p, p, whose area is A = Au + Av + Aw. The barycentric coordinates of x are named u, v and w, and are defined as follows: p Av x Au Aw p p u = Au /A, v = Av /A, w = Aw /A = u v. For example: if x = p, u =, v =, w =, if x = p, u =, v =, w =, if x = p, u =, v =, w =, if x is on the p, p edge, u =, if x is on the p, p edge, v =, if x is on the p, p edge, w =. The areas can be found by the trigonometric relation: A = /ab sin θ, b h where a and b are two sides of a triangle and θ is the angle between them. Note that sin θ = h/b, so a h = b sin θ. Therefore, A = /ah = /ab sin θ. We know that the magnitude of the cross product ka bk = kakkbk sin θ, so we can use cross product to determine areas. We can do even better if we note that a b = n, ka bk b n a where n is the normal to the plane defined by a, b and a common vertex. Now, referring to the diagram to the right, let p e = p p, n e = p p, e = p p, n = (e e )/ke e k. e Av x Au e Aw p e p

9.. A SPECIAL CASE: RAY-TRIANGLE INTERSECTION 59 We see that A = (e e ) n, A u = [e (x p )] n, A v = [e (x p )] n. This gives us u = A u /A, v = A v /A, w = u v. Note that computation with dot product instead of absolute value gives us a signed area. This means that if x is outside of a triangle, at least one of the u, v, w coordinates will be negative, as demonstrated in the following figures. p x n e p p Note that [e (x p )] n < so u <. x p e p e p Note that A u + A w > A, so u + w >, thus v <. So given triangle p, p, p, a compact way to calculate the barycentric coordinates of D point x with respect to this triangle consists of the following steps: v n = (p p ) (p p ), A = v n, n = v n /A u = [(p p ) (x p )] n/a, v = [(p p ) (x p )] n/a, w = u v. Note: the A in the above equations is actually twice the area of the triangle, but since it only is used in ratios with other areas, this scale factor is cancelled out. Now our inside/outside test is simply u, v, u + v.

6 CHAPTER 9. RAYCASTING POLYGONAL MODELS Given barycentic coordinates (u, v, w) and vertices p, p, p for a triangle, we can convert back to D coordinates by x = p + u(p p ) + v(p p ). Another way to see this is that u, v and w weight vertices to give the position of x. By rearranging the equation above, we have x = up + vp + ( u v)p. p v p p u This follows directly if we see the u and v coordinates as measuring distance from an edge to a parallel line passing through the opposite vertex as shown in the diagram to the left. We see that u measures the fraction of the full distance from edge p, p to a parallel line through p. Defined this way, u is a per unit measure, so u = on p, p, u = on the parallel line. The v coordinate is similar, measuring distance from the edge p, p, and w measures distance from p, p.