Appendix E Calculating Normal Vectors

Similar documents
Let and be a differentiable function. Let Then be the level surface given by

Curves and Surfaces Computer Graphics I Lecture 9

Lagrange Multipliers. Lagrange Multipliers. Lagrange Multipliers. Lagrange Multipliers. Lagrange Multipliers. Lagrange Multipliers

Central issues in modelling

Advanced Algebra. Equation of a Circle

Curves D.A. Forsyth, with slides from John Hart

TANGENTS AND NORMALS

The Law of Reflection

Surfaces and Partial Derivatives

Haga's Origamics. Haga's Origamics are a series of activities designed to illustrate the science behind simple paper folding.

Intro to Modeling Modeling in 3D

Licom Systems Ltd., Training Course Notes. 3D Surface Creation

Curves and Surfaces Computer Graphics I Lecture 10

Answer Key: Three-Dimensional Cross Sections

Surfaces and Integral Curves

What you will learn today

1. Use the Trapezium Rule with five ordinates to find an approximate value for the integral

Grade 6 Math Circles October 16 & Non-Euclidean Geometry and the Globe

Surface Rendering. Surface Rendering

MATH Lagrange multipliers in 3 variables Fall 2016

Lecture IV Bézier Curves

SPM Add Math Form 5 Chapter 3 Integration

Three Dimensional Geometry. Linear Programming

Describe Plane Shapes

Systems of Equations and Inequalities. Copyright Cengage Learning. All rights reserved.

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Triangle meshes I. CS 4620 Lecture 2

Surfaces and Partial Derivatives

Mathematical Analysis of Tetrahedron (solid angle subtended by any tetrahedron at its vertex)

In what follows, we will focus on Voronoi diagrams in Euclidean space. Later, we will generalize to other distance spaces.

[Anton, pp , pp ] & [Bourne, pp ]

Continuity and Tangent Lines for functions of two variables

MATERIAL FOR A MASTERCLASS ON HYPERBOLIC GEOMETRY. Timeline. 10 minutes Exercise session: Introducing curved spaces

Grade 6 Math Circles October 16 & Non-Euclidean Geometry and the Globe

The diagram above shows a sketch of the curve C with parametric equations

3 Polygonal Modeling. Getting Started with Maya 103

x 6 + λ 2 x 6 = for the curve y = 1 2 x3 gives f(1, 1 2 ) = λ actually has another solution besides λ = 1 2 = However, the equation λ

Equation of tangent plane: for implicitly defined surfaces section 12.9

Chapter 17: The Truth about Normals

Chapter III.C Analysis of The Second Derivative Draft Version 4/19/14 Martin Flashman 2005

4. TANGENTS AND NORMALS

12.7 Tangent Planes and Normal Lines

How do we draw a picture?

Solved Examples. Parabola with vertex as origin and symmetrical about x-axis. We will find the area above the x-axis and double the area.

Geometry Definitions and Theorems. Chapter 9. Definitions and Important Terms & Facts

Chapter 6. Curves and Surfaces. 6.1 Graphs as Surfaces

Triangle meshes I. CS 4620 Lecture Kavita Bala (with previous instructor Marschner) Cornell CS4620 Fall 2015 Lecture 2

Section 2.1 Graphs. The Coordinate Plane

A simple problem that has a solution that is far deeper than expected!

Geometry Vocabulary. acute angle-an angle measuring less than 90 degrees

An angle that has a measure less than a right angle.

Triangle meshes I. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2017

GEOMETRY IN THREE DIMENSIONS

Day 5: Inscribing and Circumscribing Getting Closer to π: Inscribing and Circumscribing Polygons - Archimedes Method. Goals:

Quiz 6 Practice Problems

Lesson 3: Surface Creation

1 Solution of Homework

Core Mathematics 3 Functions

03 - Reconstruction. Acknowledgements: Olga Sorkine-Hornung. CSCI-GA Geometric Modeling - Spring 17 - Daniele Panozzo

CGT 581 G Geometric Modeling Curves

Reflection & Mirrors

Geometric Primitives. Chapter 5

Mathematically, the path or the trajectory of a particle moving in space in described by a function of time.

Glossary of dictionary terms in the AP geometry units

PAST QUESTIONS ON INTEGRATION PAPER 1

CSCI 4620/8626. Coordinate Reference Frames

Math (Spring 2009): Lecture 5 Planes. Parametric equations of curves and lines

3. The three points (2, 4, 1), (1, 2, 2) and (5, 2, 2) determine a plane. Which of the following points is in that plane?

Direction Fields; Euler s Method

PARAMETRIC EQUATIONS AND POLAR COORDINATES

REVIEW I MATH 254 Calculus IV. Exam I (Friday, April 29) will cover sections

Curvature Berkeley Math Circle January 08, 2013

Optics II. Reflection and Mirrors

12.5 Lines and Planes in 3D Lines: We use parametric equations for 3D lines. Here s a 2D warm-up:

COMPUTING CONSTRAINED DELAUNAY

Does a group of parallel line segments need to be the same length?

AQA GCSE Further Maths Topic Areas

11 cm. A rectangular container is 12 cm long, 11 cm wide and 10 cm high. The container is filled with water to a depth of 8 cm.

Ray Tracing Basics I. Computer Graphics as Virtual Photography. camera (captures light) real scene. photo. Photographic print. Photography: processing

11/1/13. Visualization. Scientific Visualization. Types of Data. Height Field. Contour Curves. Meshes

Visualization. CSCI 420 Computer Graphics Lecture 26

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Substituting a 2 b 2 for c 2 and using a little algebra, we can then derive the standard equation for an ellipse centred at the origin,

Example: The following is an example of a polyhedron. Fill the blanks with the appropriate answer. Vertices:

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

1) Find. a) b) c) d) e) 2) The function g is defined by the formula. Find the slope of the tangent line at x = 1. a) b) c) e) 3) Find.

13.1. Functions of Several Variables. Introduction to Functions of Several Variables. Functions of Several Variables. Objectives. Example 1 Solution

Tutte s Theorem: How to draw a graph


Topics and things to know about them:

If the center of the sphere is the origin the the equation is. x y z 2ux 2vy 2wz d 0 -(2)

Sec 4.1 Coordinates and Scatter Plots. Coordinate Plane: Formed by two real number lines that intersect at a right angle.

Properties of Quadratic functions

( ) ( 200, 0 ) and 0, 200. Linear programming 6C. ( 40, 0) and ( 0, 80) ( 100.8,16.8) F = 168. ( 37.5, 22.5) m=97.5. Objective line passes through

Homework #2. Shading, Projections, Texture Mapping, Ray Tracing, and Bezier Curves

Scalar Field Visualization. Some slices used by Prof. Mike Bailey

From the SelectedWorks of Harish Chandra Rajpoot H.C. Rajpoot. Harish Chandra Rajpoot Rajpoot, HCR. Summer April 6, 2015

True/False. MATH 1C: SAMPLE EXAM 1 c Jeffrey A. Anderson ANSWER KEY

CONSTRUCTIONS Introduction Division of a Line Segment

Calculation of the Focal Length of an Offset Satellite Dish Antenna

Transcription:

OpenGL Programming Guide (Addison-Wesley Publishing Company) Appendix E Calculating Normal Vectors This appendix describes how to calculate normal vectors for surfaces. You need to define normals to use the OpenGL lighting facility, which is described in Chapter 5. "Normal Vectors" in Chapter 2 introduces normals and the OpenGL command for specifying them. This appendix goes through the details of calculating them. It has the following major sections: "Finding Normals for Analytic Surfaces" "Finding Normals from Polygonal Data" Since normals are perpendicular to a surface, you can find the normal at a particular point on a surface by first finding the flat plane that just touches the surface at that point. The normal is the vector that s perpendicular to that plane. On a perfect sphere, for example, the normal at a point on the surface is in the same direction as the vector from the center of the sphere to that point. For other types of surfaces, there are other, better means for determining the normals, depending on how the surface is specified. Recall that smooth curved surfaces are approximated by a large number of small flat polygons. If the vectors perpendicular to these polygons are used as the surface normals in such an approximation, the surface appears faceted, since the normal direction is discontinuous across the polygonal boundaries. In many cases, however, an exact mathematical description exists for the surface, and true surface normals can be calculated at every point. Using the true normals improves the rendering considerably, as shown in Figure E-1. Even if you don t have a mathematical description, you can do better than the faceted look shown in the figure. The two major sections in this appendix describe how to calculate normal vectors for these two cases: "Finding Normals for Analytic Surfaces" explains what to do when you have a mathematical description of a surface. "Finding Normals from Polygonal Data" covers the case when you have only the polygonal data to describe a surface. Figure E-1 : Rendering with Polygonal Normals vs. True Normals

Finding Normals for Analytic Surfaces Analytic surfaces are smooth, differentiable surfaces that are described by a mathematical equation (or set of equations). In many cases, the easiest surfaces to find normals for are analytic surfaces for which you have an explicit definition in the following form: V(s,t) = [ X(s,t) Y(s,t) Z(s,t) ] where s and t are constrained to be in some domain, and X, Y, and Z are differentiable functions of two variables. To calculate the normal, find which are vectors tangent to the surface in the s and t directions. The cross product is perpendicular to both and, hence, to the surface. The following shows how to calculate the cross product of two vectors. (Watch out for the degenerate cases where the cross product has zero length!) You should probably normalize the resulting vector. To normalize a vector [x y z], calculate its length and divide each component of the vector by the length. As an example of these calculations, consider the analytic surface V(s,t) = [ s2 t3 3-st ] From this we have So, for example, when s=1 and t=2, the corresponding point on the surface is (1, 8, 1), and the vector (-24, 2, 24) is perpendicular to the surface at that point. The length of this vector is 34, so the unit normal vector is (-24/34, 2/34, 24/34) = (-0.70588, 0.058823, 0.70588).

For analytic surfaces that are described implicitly, as F(x, y, z) = 0, the problem is harder. In some cases, you can solve for one of the variables, say z = G(x, y), and put it in the explicit form given previously: Then continue as described earlier. If you can t get the surface equation in an explicit form, you might be able to make use of the fact that the normal vector is given by the gradient evaluated at a particular point (x, y, z). Calculating the gradient might be easy, but finding a point that lies on the surface can be difficult. As an example of an implicitly defined analytic function, consider the equation of a sphere of radius 1 centered at the origin: x2 + y2 + z2-1 = 0 ) This means that F (x, y, z) = x2 + y2 + z2-1 which can be solved for z to yield Thus, normals can be calculated from the explicit form as described previously. If you could not solve for z, you could have used the gradient as long as you could find a point on the surface. In this case, it s not so hard to find a point - for example, (2/3, 1/3, 2/3) lies on the surface. Using the gradient, the normal at this point is (4/3, 2/3, 4/3). The unit-length normal is (2/3, 1/3, 2/3), which is the same as the point on the surface, as expected. Finding Normals from Polygonal Data

As mentioned previously, you often want to find normals for surfaces that are described with polygonal data such that the surfaces appear smooth rather than faceted. In most cases, the easiest way for you to do this (though it might not be the most efficient way) is to calculate the normal vectors for each of the polygonal facets and then to average the normals for neighboring facets. Use the averaged normal for the vertex that the neighboring facets have in common. Figure E-2 shows a surface and its polygonal approximation. (Of course, if the polygons represent the exact surface and aren t merely an approximation - if you re drawing a cube or a cut diamond, for example - don t do the averaging. Calculate the normal for each facet as described in the following paragraphs, and use that same normal for each vertex of the facet.) Figure E-2 : Averaging Normal Vectors To find the normal for a flat polygon, take any three vertices v1, v2, and v3 of the polygon that do not lie in a straight line. The cross product [v1 - v2] [v2 - v3] is perpendicular to the polygon. (Typically, you want to normalize the resulting vector.) Then you need to average the normals for adjoining facets to avoid giving too much weight to one of them. For instance, in the example shown in Figure E-2, if n1, n2, n3, and n4 are the normals for the four polygons meeting at point P, calculate n1+n2+n3+n4 and then normalize it. (You can get a better average if you weight the normals by the size of the angles at the shared intersection.) The resulting

vector can be used as the normal for point P. Sometimes, you need to vary this method for particular situations. For instance, at the boundary of a surface (for example, point Q in Figure E-2), you might be able to choose a better normal based on your knowledge of what the surface should look like. Sometimes the best you can do is to average the polygon normals on the boundary as well. Similarly, some models have some smooth parts and some sharp corners (point R is on such an edge in Figure E-2). In this case, the normals on either side of the crease shouldn t be averaged. Instead, polygons on one side of the crease should be drawn with one normal, and polygons on the other side with another. OpenGL Programming Guide (Addison-Wesley Publishing Company)