CMSC 425: Lecture 4 Geometry and Geometric Programming

Similar documents
CMSC 425: Lecture 7 Geometric Programming: Sample Solutions

Planar Transformations and Displacements

Chapter 7 Rational and Irrational Numbers

Solutions to Assignment #02 MATH u v p 59. p 72. h 3; 1; 2i h4; 2; 5i p 14. p 45. = cos 1 2 p!

Session 5: Review of Classical Astrodynamics

8 STOCHASTIC PROCESSES

Complex Analysis Homework 1

Lecture 1.2 Pose in 2D and 3D. Thomas Opsahl

A Special Case Solution to the Perspective 3-Point Problem William J. Wolfe California State University Channel Islands

ε i (E j )=δj i = 0, if i j, form a basis for V, called the dual basis to (E i ). Therefore, dim V =dim V.

8.7 Associated and Non-associated Flow Rules

Pretest (Optional) Use as an additional pacing tool to guide instruction. August 21

Principal Components Analysis and Unsupervised Hebbian Learning

MATH 2710: NOTES FOR ANALYSIS

Computer arithmetic. Intensive Computation. Annalisa Massini 2017/2018

Lecture 1.2 Units, Dimensions, Estimations 1. Units To measure a quantity in physics means to compare it with a standard. Since there are many

2 Asymptotic density and Dirichlet density

2 Asymptotic density and Dirichlet density

EXERCISES Practice and Problem Solving

19th Bay Area Mathematical Olympiad. Problems and Solutions. February 28, 2017

Section 0.10: Complex Numbers from Precalculus Prerequisites a.k.a. Chapter 0 by Carl Stitz, PhD, and Jeff Zeager, PhD, is available under a Creative

Numerical Linear Algebra

Multiplicative group law on the folium of Descartes

PHYS 301 HOMEWORK #9-- SOLUTIONS

2016-r1 Physics 220: Worksheet 02 Name

Principles of Computed Tomography (CT)

Cryptanalysis of Pseudorandom Generators

Find the equation of a plane perpendicular to the line x = 2t + 1, y = 3t + 4, z = t 1 and passing through the point (2, 1, 3).

A Simple And Efficient FEM-Implementation Of The Modified Mohr-Coulomb Criterion Clausen, Johan Christian; Damkilde, Lars

Solved Problems. (a) (b) (c) Figure P4.1 Simple Classification Problems First we draw a line between each set of dark and light data points.

δ(xy) = φ(x)δ(y) + y p δ(x). (1)

= ( 2) = p 5.

Feedback-error control

Solution sheet ξi ξ < ξ i+1 0 otherwise ξ ξ i N i,p 1 (ξ) + where 0 0

SECTION 5: FIBRATIONS AND HOMOTOPY FIBERS

Lower bound solutions for bearing capacity of jointed rock

DIFFERENTIAL GEOMETRY. LECTURES 9-10,

Trigonometric Identities

State Estimation with ARMarkov Models

Use of Transformations and the Repeated Statement in PROC GLM in SAS Ed Stanek

Economics 101. Lecture 7 - Monopoly and Oligopoly

1 Properties of Spherical Harmonics

Math 121: Calculus 1 - Fall 2012/2013 Review of Precalculus Concepts

arxiv: v1 [physics.data-an] 26 Oct 2012

7.1 Projections and Components

Pretest (Optional) Use as an additional pacing tool to guide instruction. August 21

Statics and dynamics: some elementary concepts

CHAPTER 5 TANGENT VECTORS

HENSEL S LEMMA KEITH CONRAD

MORE TRIGONOMETRIC FUNCTIONS

Elementary Analysis in Q p

SYMPLECTIC STRUCTURES: AT THE INTERFACE OF ANALYSIS, GEOMETRY, AND TOPOLOGY

BME 207 Introduction to Biomechanics Spring Homework 1

Generalized exterior forms, geometry and space-time

Topic 7: Using identity types

A QUATERNIONIC APPROACH to GEOMETRY of CURVES on SPACES of CONSTANT CURVATURE

FORMAL DEFINITION OF TOLERANCING IN CAD AND METROLOGY

STA 250: Statistics. Notes 7. Bayesian Approach to Statistics. Book chapters: 7.2

FFTs in Graphics and Vision. Rotational and Reflective Symmetry Detection

(IV.D) PELL S EQUATION AND RELATED PROBLEMS

Introduction to Group Theory Note 1

9.4 Polar Coordinates

Elliptic Curves Spring 2015 Problem Set #1 Due: 02/13/2015

On the Toppling of a Sand Pile

John Weatherwax. Analysis of Parallel Depth First Search Algorithms

Model checking, verification of CTL. One must verify or expel... doubts, and convert them into the certainty of YES [Thomas Carlyle]

Elements of Asymptotic Theory. James L. Powell Department of Economics University of California, Berkeley

0.1 Practical Guide - Surface Integrals. C (0,0,c) A (0,b,0) A (a,0,0)

CSE 599d - Quantum Computing When Quantum Computers Fall Apart

Correspondence Between Fractal-Wavelet. Transforms and Iterated Function Systems. With Grey Level Maps. F. Mendivil and E.R.

Uncorrelated Multilinear Principal Component Analysis for Unsupervised Multilinear Subspace Learning

Churilova Maria Saint-Petersburg State Polytechnical University Department of Applied Mathematics

Sets of Real Numbers

Measuring center and spread for density curves. Calculating probabilities using the standard Normal Table (CIS Chapter 8, p 105 mainly p114)

Elementary theory of L p spaces

Network Configuration Control Via Connectivity Graph Processes

MULTIVARIATE STATISTICAL PROCESS OF HOTELLING S T CONTROL CHARTS PROCEDURES WITH INDUSTRIAL APPLICATION

Solutions to Problem Set 5

Chapter 1: PROBABILITY BASICS

MATH 361: NUMBER THEORY ELEVENTH LECTURE

Microeconomics Fall 2017 Problem set 1: Possible answers

Spin as Dynamic Variable or Why Parity is Broken

Short Solutions to Practice Material for Test #2 MATH 2421

A Solution for the Dark Matter Mystery based on Euclidean Relativity

HEAT, WORK, AND THE FIRST LAW OF THERMODYNAMICS

jf 00 (x)j ds (x) = [1 + (f 0 (x)) 2 ] 3=2 (t) = jjr0 (t) r 00 (t)jj jjr 0 (t)jj 3

Excerpt from "Intermediate Algebra" 2014 AoPS Inc.

Collaborative Place Models Supplement 1

Series Handout A. 1. Determine which of the following sums are geometric. If the sum is geometric, express the sum in closed form.

COMMUNICATION BETWEEN SHAREHOLDERS 1

0.6 Factoring 73. As always, the reader is encouraged to multiply out (3

pp physics, RWTH, WS 2003/04, T.Hebbeker

Measuring center and spread for density curves. Calculating probabilities using the standard Normal Table (CIS Chapter 8, p 105 mainly p114)

CHAPTER 2: SMOOTH MAPS. 1. Introduction In this chapter we introduce smooth maps between manifolds, and some important

The Arm Prime Factors Decomposition

RESOLUTIONS OF THREE-ROWED SKEW- AND ALMOST SKEW-SHAPES IN CHARACTERISTIC ZERO

Implementation and Validation of Finite Volume C++ Codes for Plane Stress Analysis

Characteristics of Fibonacci-type Sequences

Scaling Multiple Point Statistics for Non-Stationary Geostatistical Modeling

16.2. Infinite Series. Introduction. Prerequisites. Learning Outcomes

Transcription:

CMSC 425: Lecture 4 Geometry and Geometric Programming Geometry for Game Programming and Grahics: For the next few lectures, we will discuss some of the basic elements of geometry. There are many areas of comuter science that involve comutation with geometric entities. This includes not only comuter grahics, but also areas like comuter-aided design, robotics, comuter vision, and geograhic information systems. While software systems like Unity rovide suort to do geometry for you, there are good reasons for learning this material. First, for those of you who will go on to design the successor to Unity, it is imortant to understand the fundamentals underlying gometric rogramming. Second, as a game rogrammer, you will find that there things that Unity cannot hel with. In such cases, you will need to write scrits to do the geometry yourself. Comuter grahics deals largely with the geometry of lines and linear objects in 3-sace, because light travels in straight lines. For examle, here are some tyical geometric roblems that arise in designing rograms for comuter grahics. Transformations: You are asked to render a twirling boomerang flying through the air. How would you reresent the boomerang s rotation and translation over time in 3-dimensional sace? How would you comute its exact osition at a articular time? Geometric Intersections: Given the same boomerang, how would you determine whether it has hit another object? Orientation: You have been asked to design the AI for a non-layer agent in a flight combat simulator. You detect the resence of a enemy aircraft in a certain direction. How should you rotate your aircraft to either attack (or escae from) this threat? Change of coordinates: We know the osition of an object on a table with resect to a coordinate system associated with the table. We know the osition of the table with resect to a coordinate system associated with the room. What is the osition of the object with resect to the coordinate system associated with the room? Reflection and refraction: We would like to simulate the way that light reflects off of shiny objects and refracts through transarent objects. Such basic geometric roblems are fundamental to comuter grahics, and over the next few lectures, our goal will be to resent the tools needed to answer these sorts of uestions. There are various formal geometric systems that arise naturally in game rogramming and comuter grahics. The rincial ones are: Affine Geometry: The geometry of simle flat things : oints, lines, lanes, line segments, triangles, etc. There is no defined notion of distance, angles, or orientations, however. Euclidean Geometry: The geometric system that is most familiar to us. It enhances affine geometry by adding notions such as distances, angles, and orientations (such as clockwise and counterclockwise). Projective Geometry: In Euclidean geometry, there is no notion of infinity (in the same way that in standard arithmetic, you cannot divide by zero). But in grahics, we often need to deal with infinity. (For examle, two arallel lines in 3-dimensional sace can Lecture 4 1 Sring 2018

meet at a common vanishing oint in a ersective rendering. Think of the oint in the distance where two erfectly straight train tracks aear to meet. Comuting this vanishing oint involves oints at infinity.) Projective geometry ermits this. Affine Geometry: Affine geometry is basic to all geometric rocessing. It s basic elements are: Scalars, which we can just think of as being real numbers Points, which define locations in sace Free vectors (or simly vectors), which are used to secify direction and magnitude, but have no fixed osition. The term free means that vectors do not necessarily emanate from some osition (like the origin), but float freely about in sace. There is a secial vector called the zero vector, 0, that has no magnitude, such that v + 0 = 0 + v = v. Note that we did not define a zero oint or origin for affine sace. This is an intentional omission. No oint secial comared to any other oint. (We will eventually have to break down and define an origin in order to have a coordinate system for our oints, but this is a urely reresentational necessity, not an intrinsic feature of affine sace.) You might ask, why make a distinction between oints and vectors? 1 Although both can be reresented in the same way as a list of coordinates, they reresent very different concets. For examle, oints would be aroriate for reresenting a vertex of a mesh, the center of mass of an object, the oint of contact between two colliding objects. In contrast, a vector would be aroriate for reresenting the velocity of a moving object, the vector normal to a surface, the axis about which a rotating object is sinning. (As comuter scientists the idea of different abstract objects sharing a common reresentation should be familiar. For examle, stacks and ueues are two different abstract data tyes, but they can both be reresented as a 1-dimensional array.) Because oints and vectors are concetually different, it is not surrising that the oerations that can be alied to them are different. For examle, it makes erfect sense to multily a vector and a scalar. Geometrically, this corresonds to stretching the vector by this amount. It also makes sense to add two vectors together. This involves the usual head-to-tail rule, which you learn in linear algebra. It is not so clear, however, what it means to multily a oint by a scalar. (For examle, the to of the Washington monument is a oint. What would it mean to multily this oint by 2?) On the other hand, it does make sense to add a vector to a oint. For examle, if a vector oints straight u and is three meters long, then adding this to the to of the Washington monument would naturally give you a oint that is three meters above the to of the monument. We will use the following notational conventions. Points will usually be denoted by lower-case Roman letters such as,, and r. Vectors will usually be denoted with lower-case Roman letters, such as u, v, and w, and often to emhasize this we will add an arrow (e.g., u, v, w). Scalars will be reresented as lower case Greek letters (e.g., α, β, γ). In our rograms, scalars will be translated to Roman (e.g., a, b, c). (We will sometimes violate these conventions, 1 Unity does not distinguish between them. The data tye Vector3 is used to reresent both oints and vectors. Lecture 4 2 Sring 2018

however. For examle, we may use c to denote the center oint of a circle or r to denote the scalar radius of a circle.) Affine Oerations: The table below lists the valid combinations of scalars, oints, and vectors. The formal definitions are retty much what you would exect. Vector oerations are alied in the same way that you learned in linear algebra. For examle, vectors are added in the usual tail-to-head manner (see Fig. 1). The difference of two oints results in a free vector directed from to. Point-vector addition r + v is defined to be the translation of r by dislacement v. Note that some oerations (e.g. scalar-oint multilication, and addition of oints) are exlicitly not defined. vector scalar vector, vector vector/scalar scalar-vector multilication vector vector + vector, vector vector vector vector-vector addition vector oint oint oint-oint difference oint oint + vector, oint oint vector oint-vector addition u u + v v r v r + v Vector addition Point subtraction Point-vector addition Fig. 1: Affine oerations. Affine Combinations: Although the algebra of affine geometry has been careful to disallow oint addition and scalar multilication of oints, there is a articular combination of two oints that we will consider legal. The oeration is called an affine combination. Let s say that we have two oints and and want to comute their midoint r, or more generally a oint r that subdivides the line segment into the roortions α and 1 α, for some α [0, 1]. (The case α = 1/2 is the case of the midoint). This could be done by taking the vector, scaling it by α, and then adding the result to. That is, r = + α( ), (see Fig. 2(a)). Another way to think of this oint r is as a weighted average of the endoints and. Thinking of r in these terms, we might be temted to rewrite the above formula in the following (technically illegal) manner: r = (1 α) + α, (see Fig. 2(b)). Observe that as α ranges from 0 to 1, the oint r ranges along the line segment from to. In fact, we may allow to become negative in which case r lies to the left of, and if α > 1, then r lies to the right of (see Fig. 2(c)). The secial case when 0 α 1, this is called a convex combination. In general, we define the following two oerations for oints in affine sace. Lecture 4 3 Sring 2018

r = + 2 3 ( ) 1 3 + 2 3 α < 0 1 2 + 1 4 r + 1 4 0 < α < 1 (1 α) + α α > 1 (a) (b) (c) (d) Fig. 2: Affine combinations. r 0 + 1 2 r + 1 2 Affine combination: Given a seuence of oints 1, 2,..., n, an affine combination is any sum of the form α 1 1 + α 2 2 +... + α n n, where α 1, α 2,..., α n are scalars satisfying i α i = 1. Convex combination: Is an affine combination, where in addition we have α i 0 for 1 i n. Affine and convex combinations have a number of nice uses in grahics. For examle, any three noncollinear oints determine a lane. There is a 1 1 corresondence between the oints on this lane and the affine combinations of these three oints. Similarly, there is a 1 1 corresondence between the oints in the triangle determined by the these oints and the convex combinations of the oints (see Fig. 2(d)). In articular, the oint 1 3 + 1 3 + 1 3 r is the centroid of the triangle. We will sometimes be sloy, and write exressions like 1 2 ( + ), which really means 1 2 + 1 2. We will allow this sort of abuse of notation rovided that it is clear that there is a legal affine combination that underlies this oeration. To see whether you understand the notation, consider the following uestions. Given three oints in the 3-sace, what is the union of all their affine combinations? (Ans: the lane containing the 3 oints.) What is the union of all their convex combinations? (Ans: The triangle defined by the three oints and its interior.) Euclidean Geometry: In affine geometry we have rovided no way to talk about angles or distances. Euclidean geometry is an extension of affine geometry which includes one additional oeration, called the inner roduct. The inner roduct is an oerator that mas two vectors to a scalar. The roduct of u and v is denoted commonly denoted ( u, v). There are many ways of defining the inner roduct, but any legal definition should satisfy the following reuirements Positiveness: ( u, u) 0 and ( u, u) = 0 if and only if u = 0. Symmetry: ( u, v) = ( v, u). Bilinearity: ( u, v + w) = ( u, v) + ( u, w), and ( u, α v) = α( u, v). (Notice that the symmetric forms follow by symmetry.) See a book on linear algebra for more information. We will focus on a the most familiar inner roduct, called the dot roduct. To define this, we will need to get our hands dirty with Lecture 4 4 Sring 2018

coordinates. Suose that the d-dimensional vector u is reresented by the coordinate vector (u 0, u 1,..., u d 1 ). Then define d 1 u v = u i v i, Note that inner (and hence dot) roduct is defined only for vectors, not for oints. i=0 Using the dot roduct we may define a number of concets, which are not defined in regular affine geometry (see Fig. 3). Note that these concets generalize to all dimensions. Length: of a vector v is defined to be v v, and is denoted by v (or as v ). Normalization: Given any nonzero vector v, define the normalization to be a vector of unit length that oints in the same direction as v, that is, v/ v. We will denote this by v. Distance between oints: dist(, ) =. Angle: between two nonzero vectors u and v (ranging from 0 to π) is ( ) u v ang( u, v) = cos 1 = cos 1 (û v). u v This is easy to derive from the law of cosines. Note that this does not rovide us with a signed angle. We cannot tell whether u is clockwise our counterclockwise relative to v. We will discuss signed angles when we consider the cross-roduct. Orthogonality: u and v are orthogonal (or erendicular) if u v = 0. Orthogonal rojection: Given a vector u and a nonzero vector v, it is often convenient to decomose u into the sum of two vectors u = u 1 + u 2, such that u 1 is arallel to v and u 2 is orthogonal to v. u 1 ( u v) ( v v) v, u 2 u u 1. (As an exercise, verify that u 2 is orthogonal to v.) Note that we can ignore the denominator if we know that v is already normalized to unit length. The vector u 1 is called the orthogonal rojection of u onto v. If we think of v as being a normal vector to a lane, then the rojection of u onto this lane is called orthogonal comlement of u with resect to v, and is given by u 2 u u 1. u θ v Angle between vectors u u 2 v u 1 Orthogonal rojection and its comlement Fig. 3: The dot roduct and its uses. Lecture 4 5 Sring 2018

Doing it with Unity: Unity does not distinguish between oints and vectors. Both are reresented using Vector3. Unity suorts many of the vector oerations by overloading oerators. Given vectors u, v, and w, all of tye Vector3, the following oerators are suorted: u = v + w; // vector addition u = v - w; // vector subtraction if (u == v u!= w) {... } // vector comarison u = v * 2.0 f; // scalar multilication v = w / 2.0 f; // scalar division You can access the comonents of a Vector3 using as either using axis names, such as, u.x, u.y, and u.z, or through indexing, such as u[0], u[1], and u[2]. The Vector3 class also has the following members and static functions. float x = v. magnitude ; // length of v Vector3 u = v. normalize ; // unit vector in v s direction float a = Vector3. Angle ( u, v); // angle ( degrees ) between u and v float b = Vector3. Dot ( u, v); // dot roduct between u and v Vector3 u1 = Vector3. Project ( u, v); // orthog roj of u onto v Vector3 u2 = Vector3. ProjectOnPlane ( u, v); // orthogonal comlement Some of the Vector3 functions aly when the objects are interreted as oints. Let and be oints declared to be of tye Vector3. The function Vector3.Ler is short for linear interolation. It is essentially a two-oint secial case of a convex combination. (The combination arameter is assumed to lie between 0 and 1.) float b = Vector3. Distance (, ); // distance between and Vector3 midoint = Vector3. Ler (,, 0.5 f); // convex combination Lecture 4 6 Sring 2018