Introduction to 3D Game Programming with DirectX 9.0c: A Shader Approach

Similar documents
Exercise Solutions for Introduction to 3D Game Programming with DirectX 10

Rigid Body Transforms-3D. J.C. Dill transforms3d 27Jan99

Mathematics 309 Conic sections and their applicationsn. Chapter 2. Quadric figures. ai,j x i x j + b i x i + c =0. 1. Coordinate changes

VECTORS IN THREE DIMENSIONS

9.1 VECTORS. A Geometric View of Vectors LEARNING OBJECTIVES. = a, b

( ) ( ) ( ) ( ) TNM046: Datorgrafik. Transformations. Linear Algebra. Linear Algebra. Sasan Gooran VT Transposition. Scalar (dot) product:

we must pay attention to the role of the coordinate system w.r.t. which we perform a tform

Reading. 4. Affine transformations. Required: Watt, Section 1.1. Further reading:

9.1 VECTORS. A Geometric View of Vectors LEARNING OBJECTIVES. = a, b

we must pay attention to the role of the coordinate system w.r.t. which we perform a tform

10.2 The Unit Circle: Cosine and Sine

Vector and Affine Math

MATRIX TRANSFORMATIONS

ES.1803 Topic 16 Notes Jeremy Orloff

2D Geometric Transformations. (Chapter 5 in FVD)

CS 378: Computer Game Technology

Dot Products. K. Behrend. April 3, Abstract A short review of some basic facts on the dot product. Projections. The spectral theorem.

Affine transformations

Three-Dimensional Space; Vectors

Mathematics Trigonometry: Unit Circle

1 HOMOGENEOUS TRANSFORMATIONS

15. Eigenvalues, Eigenvectors

APPENDIX D Rotation and the General Second-Degree Equation

Overview. Distances in R 3. Distance from a point to a plane. Question

MAT 1275: Introduction to Mathematical Analysis. Graphs and Simplest Equations for Basic Trigonometric Functions. y=sin( x) Function

Demonstrate solution methods for systems of linear equations. Show that a system of equations can be represented in matrix-vector form.

Identifying second degree equations

Analytic Geometry in Three Dimensions

4 The Cartesian Coordinate System- Pictures of Equations

11.4 Polar Coordinates

Section 8.2 Vector Angles

Section 10.7 The Cross Product

Affine transformations. Brian Curless CSE 557 Fall 2014

UNCORRECTED SAMPLE PAGES. 3Quadratics. Chapter 3. Objectives

The notes cover linear operators and discuss linear independence of functions (Boas ).

Transformations. Chapter D Transformations Translation

CS 354R: Computer Game Technology

3.3.1 Linear functions yet again and dot product In 2D, a homogenous linear scalar function takes the general form:

STUDY KNOWHOW PROGRAM STUDY AND LEARNING CENTRE. Functions & Graphs

F F. proj cos( ) v. v proj v

Rigid Geometric Transformations

9.2. Cartesian Components of Vectors. Introduction. Prerequisites. Learning Outcomes

And similarly in the other directions, so the overall result is expressed compactly as,

EXERCISES FOR SECTION 3.1

Physically Based Rendering ( ) Geometry and Transformations

APPENDIXES. B Coordinate Geometry and Lines C. D Trigonometry E F. G The Logarithm Defined as an Integral H Complex Numbers I

Lecture 5. Equations of Lines and Planes. Dan Nichols MATH 233, Spring 2018 University of Massachusetts.

Review of Linear Algebra

Worksheet #1. A little review.

Determinants. We said in Section 3.3 that a 2 2 matrix a b. Determinant of an n n Matrix

12 VECTOR GEOMETRY Vectors in the Plane

Homework Notes Week 6

Section 1.2 A Catalog of Essential Functions

. This is the Basic Chain Rule. x dt y dt z dt Chain Rule in this context.

Notes on multivariable calculus

Rigid Geometric Transformations

A Tutorial on Euler Angles and Quaternions

Grade 12 Mathematics. unimaths.co.za. Revision Questions. (Including Solutions)

Linear and affine transformations

Geometry review, part I

LESSON 35: EIGENVALUES AND EIGENVECTORS APRIL 21, (1) We might also write v as v. Both notations refer to a vector.

Two conventions for coordinate systems. Left-Hand vs Right-Hand. x z. Which is which?

Affine transformations

MTAEA Vectors in Euclidean Spaces

Trigonometric Functions

Practice Questions for Midterm 2 - Math 1060Q - Fall 2013

Mathematical Foundations: Intro

Vocabulary. The Pythagorean Identity. Lesson 4-3. Pythagorean Identity Theorem. Mental Math

Trigonometric Functions

The standard form of the equation of a circle is based on the distance formula. The distance formula, in turn, is based on the Pythagorean Theorem.

Mon Apr dot product, length, orthogonality, projection onto the span of a single vector. Announcements: Warm-up Exercise:

Chapter 1 Coordinates, points and lines

TENSOR TRANSFORMATION OF STRESSES

UNCORRECTED. To recognise the rules of a number of common algebraic relations: y = x 1 y 2 = x

Linear Equations and Vectors

22A-2 SUMMER 2014 LECTURE Agenda

Directional derivatives and gradient vectors (Sect. 14.5) Directional derivative of functions of two variables.

MA123, Chapter 1: Equations, functions and graphs (pp. 1-15)

Worksheet 1.3: Introduction to the Dot and Cross Products

Vector Geometry. Chapter 5

Graphics Example: Type Setting

Lecture 2: Vector-Vector Operations

Special Mathematics Notes

CS 4300 Computer Graphics. Prof. Harriet Fell Fall 2011 Lecture 11 September 29, 2011

Chapter 1 Graph of Functions

The first change comes in how we associate operators with classical observables. In one dimension, we had. p p ˆ

Eigenvectors and Eigenvalues 1

Not for reproduction

Coordinate geometry. + bx + c. Vertical asymptote. Sketch graphs of hyperbolas (including asymptotic behaviour) from the general

Review of Prerequisite Skills, p. 350 C( 2, 0, 1) B( 3, 2, 0) y A(0, 1, 0) D(0, 2, 3) j! k! 2k! Section 7.1, pp

5.3.3 The general solution for plane waves incident on a layered halfspace. The general solution to the Helmholz equation in rectangular coordinates

Elementary maths for GMT

15.4 Equation of a Circle

The Dot Product

All parabolas through three non-collinear points

Section 1.2 A Catalog of Essential Functions

Linear Algebra. 1.1 Introduction to vectors 1.2 Lengths and dot products. January 28th, 2013 Math 301. Monday, January 28, 13

Systems of Linear Equations: Solving by Graphing

Cubic and quartic functions

Chapter 8 More About the Trigonometric Functions

Transcription:

Introduction to 3D Game Programming with DirectX 90c: A Shader Approach Part I Solutions Note : Please email to frank@moon-labscom if ou find an errors Note : Use onl after ou have tried, and struggled with, the problems ourself Chapter Vector Algebra Let u (,, 0) and v ( 3, 4, 0) Compute u+ v and draw the vectors relative to a coordinate sstem v, u v, u+ v, and u + v u+ v,, 0 + 3, 4, 0 + 3, + 4, 0 + 0 4,, 0 u v,, 0 3, 4, 0 3, 4, 0 0, 6,0 u+,,0 + 3, 4,0 + 3,4+,0+ 0 7,,0 u+ v,,0 + 3, 4,0 + 3, 4+ 4,0+ 0, 8,0 Frank Luna Page 6/7/006

Let u (,, 4) and v ( 3, 4, ) Normalize u and v u n v n u,, 4 (,, 4) 4,, u + + 4 v 3, 4, ( 3, 4, ) 3 4,, v 3 + 4 + 6 6 6 6 3 Show u u has a length of one unit (Hint: Compute the length of u u ) he length of u u ( u u, u u, uz u ) is given b: u u u u u z + u + uz + u + uz u + + u u u u u u 4 Is the angle between u and v orthogonal, acute, or obtuse? a u (,, ), v (,, ) b u (,, 0), v (,, 0) u,, v 3,, 0 c, Use the geometric properties of the dot product given on page 0: (,, ) (,, ) + + 6 > 0 acute angle (,, 0) (,, 0) ( ) + + 0 0 0 orthogonal (,, ) ( 3,, 0) ( ) 3+ ( ) + ( ) 0 4 < 0 obtuse angle 5 Let u (,, 4) and v ( 3, 4, ) Find the angle θ between u and v Use Equation 4: Frank Luna Page 6/7/006

u v u v cosθ u v cosθ u v u v θ cos u v (,, 4) ( 3, 4,) θ cos + + 4 3 + 4 + 6 4+ 4 θ cos 6 6 θ cos 546 θ 0488 6 Let u ( u, u, uz), v ( v, v, vz), and w ( w, w, wz) 3 properties are true for : a u v v u b u ( v + w ) u v + u w k u v ku v u kv d v v v e 0 v 0 c (Hint: Just use the definition, for eample, v v v v + v v + v v v + v + v v + v + v v z z z z, show that the following ) a) b) u v u u u v v v (,, z) (,, z) uv + uv + uv z z vu + vu + vu z z ( v, v, vz) ( u, u, uz) v u Frank Luna Page 3 6/7/006

u v+ w u u u v v v + w w w (,, ) (,, ) (,, ) z z z ( u, u, uz) ( v + w, v + w, vz + wz) u ( v + w ) + u ( v + w ) + u ( v + w ) z z z uv + uw + uv + uw + uv + uw z z z z ( uv uv uv z z) ( uw uw uw z z) + + + + + u v+ u w c) k u v k u v u v u v ( ) ( + + z z) ku v + ku v + ku v ( ku ) z z ku v + ku v + ku v v z z k u v k u v u v u v ( ) ( + + z z) ku v + ku v + ku v z z u kv + u kv + u kv u z z ( kv) d) v v vv + vv + vzvz v + v + vz ( v + v + vz ) ( v ) 0 v 0,0,0 v, v, v 0v + 0v + 0v 0 e) z z 7 Use the Law of Cosines ( c a + b abcosθ, where a, b, and c are the lengths of the sides of a triangle and θ is the angle between sides a and b) to show uv + uv + uv u v cosθ (Hint: Draw a picture and set c u v, a u, z z and b v, and use the dot product properties from the previous eercise) Frank Luna Page 4 6/7/006

he figure shows the setup, then b the Law of Cosines: c a + b ab cosθ u v u + v u v cosθ ( ) ( u v) u v u v u v u + v u v cosθ u u u v + v v u + v u v cosθ u u v + v u + v u v cosθ u v u v cosθ cosθ uv + uv + uv u v cosθ z z 8 Let v ( 4, 3, 0) and n ( 5, 5,0) Show that n is a unit vector and find the orthogonal projection, p, of v on n hen find a vector w orthogonal to n such that v p+ w (Hint: Draw the vectors for insight, what does v p look like?) We have, n 5 + 5 + 0 + 4 5 5 So n is a unit vector o find the projection, we use the equation below Figure 8: p v n n ( 4, 3, 0) ( 5, 5, 0) 8 3 ( 5 5) n + n If v p+ w 5 (,,0) 5 5 5 (,,0) 5 5 n, then ( 0 5 4,3,0,,0,,0 ) (,,0 ) ( w v p, 4,0 ) Moreover, because to n 9 Let u (,, 4) 4 4 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5,,0,,0 + 0, we have that w is orthogonal and v ( 3, 4, ), and show wu 0 and wv 0 Find w u v Frank Luna Page 5 6/7/006

Appl Equation 5: u v (,, 4) ( 3, 4,) ( 7,4, 5) ( 4 4,4 3, 4 3) wu 7,4, 5,, 4 7 + 4 + 5 4 0 wv 7,4, 5 3, 4, 7 3 4 4 + 5 0 0 Let the following points define a triangle relative to some coordinate sstem: A 0, 0, 0 B 0,, 3 C 5,, 0 Find a vector orthogonal to this triangle,, and (Hint: Find two vectors on two of the triangle s edges and use the cross product) he two vectors on the edges of the triangle are: u B A ( 0,, 3) v C A 5,, 0 hen a vector orthogonal to this triangle is given b: u v ( 0,, 3) ( 5,, 0) ( 3,5, 5) Suppose that we have frames A and B Let p (,, 0) and q (,, 0) represent a point and force, respectivel, relative to frame A Moreover, let O ( 6,, 0), u (,,0), v (,,0), and w ( 0, 0,) describe p,, z q,, z that describe the frame A relative to frame B Find point and force relative to frame B B A and pb u v+ 0w+ O + 6, +,0,,0 q u+ v+ 0 w, +,0,,0 B Let p() t (, ) + t(, ) on the ra at t 00, 05, 0, 0, and 50 he points are: p t + p t + (, ) 0 (, ) (, ) () (, ) (, ) (, 3 ) 3 6 ( ) ( ) 3 B be a ra relative to some coordinate sstem Plot the points A Frank Luna Page 6 6/7/006

And the plot: p t + p t + () (, ) (, ) ( 3, ) () (, ) (, ) ( 5, 3) p() t (, ) + 5 (, ) (, 6) 3 Let p 0 and p define the endpoints of a line segment Show that the equation for a line segment can also be written as p ( t) ( t) p 0 + tp for [ ] 0, p t p + t p p p + tp tp t p + tp () ( ) 0 0 0 0 0 t 4 Rewrite the program in 8 twice; first using D vectors (D3DXVECOR) and second using 4D vectors (D3DXVECOR4) (Hint: Search the inde for these kewords in the DirectX SDK documentation: D3DXVECOR, D3DXVECOR4, D3DXVec, and D3DXVec4) We rewrite the program using D3DXVECOR; the other case is analogous #include <d3d9h> #include <iostream> using namespace std; // Overload the "<<" operators so that we can use cout to // output D3DXVECOR objects ostream& operator<<(ostream& os, D3DXVECOR& v) { os << "(" << v << ", " << v << ")"; return os; } int main() { // Using constructor, D3DXVECOR(FLOA, FLOA ); D3DXVECOR u(0f, 0f); Frank Luna Page 7 6/7/006

// Using constructor, D3DXVECOR(CONS FLOA *); float [] {-0f, 0f}; D3DXVECOR v(); // Using default constructor, D3DXVECOR(); D3DXVECOR a, b, c, d; // Vector addition: D3DXVECOR operator + a u + v; // Vector subtraction: D3DXVECOR operator - b u - v; // Scalar multiplication: D3DXVECOR operator * c u * 0; // u float length D3DXVecLength(&u); // d u / u D3DXVecNormalize(&d, &u); // s u dot v float s D3DXVecDot(&u, &v); cout << "u " << u << endl; cout << "v " << v << endl; cout << "a " << a << endl; cout << "b " << b << endl; cout << "c " << c << endl; cout << "d " << d << endl; cout << " u " << length << endl; cout << "u dot v " << s << endl; } return 0; Chapter Matri Algebra Let 3 0 0 0 0 0 0 0 0 0 S 0 0 0, 0 0 4 0 0 0 0 0 0 0 5 Compute the following matri products: S, S, us, u, and u [ ], and u( S) Just use the definition of matri multiplication (ie, Equation ): Does S S? Frank Luna Page 8 6/7/006

3 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 S 0 0 4 00 0 0 0 0 4 0 0 0 0 5 5 0 0 0 3 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 S 0 0 00 0 4 0 0 0 4 0 5 0 0 0 6 0 4 3 0 0 0 0 0 0 us [ ] [ 6 4 ] 0 0 4 0 0 0 0 0 0 0 0 0 0 u [ ] [ 4 6 0 ] 0 0 0 5 3 0 0 0 0 0 0 0 0 0 0 0 0 u S 8 3 3 0 0 4 00 0 0 0 0 0 5 S [ ] [ ] S v Show uv u, u, u z v u v v z he notation uv means the product of a 3 row vector u with a 3 column vector v so that the matri product is defined B the definition of matri multiplication we have that the product of a 3 matri with a 3 matri is a matri; we can think of a matri as just a scalar Appling Equation we obtain: v u, u, u z v uv uv uv + + z z uv + uv + uv z z u v v z his eercise simpl shows that we can epress a dot product in matri notation using matri multiplication Frank Luna Page 9 6/7/006

3 Using S and from Eercise, compute? Does S S? S,, and ( ) S and S What is S 3 0 0 0 3 0 0 0 0 0 0 0 0 0 S 0 0 4 0 0 0 4 0 0 0 0 0 0 0 Observe for this special matri, is said to b smmetric S S When a matri equals its transpose, the matri 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 5 0 0 0 ( S ) ( S ) ( ) 3 0 0 0 3 0 0 0 0 0 0 0 5 0 0 4 0 0 0 4 5 0 0 0 3 0 0 0 3 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 S 0 0 4 0 0 0 4 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 5 So if we take one transpose, we interchange the rows and columns If we take another transpose, we interchange the rows and columns again and end up back to where we started Frank Luna Page 0 6/7/006

S 0 0 3 0 0 0 3 0 0 0 0 5 0 0 0 0 0 5 0 0 0 0 4 0 0 0 4 0 0 0 0 0 0 0 0 0 ( S) 4 Using S and from Eercise, verif that D3DXMatriInverse to do the calculations) Using D3DXMatriInverse, we find that: S S (Use ( S ) 3 0 0 0 0 0 0, 0 0 0 4 5 3 4 S 3 0 0 0 0 0 0, 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 5 Using the definition of matri multiplication, we compute S 3 0 0 0 0 0 0 0 0 4 0 5 3 4 We see that indeed S S 5 Write the following linear combination as a vector-matri multiplication: v,,3 + 4 5,0, + 3,, 3 Observe: v + +,,3 4( 5,0, ) 3, (, 3) (, 4, 6) ( 0, 0, 4) ( 6, 6, 9) ( 8,, ) + + B Equation, we can write this linear combination as a vector-matri product: 3 v 3 [, 4, 3] 5 0 [ 8,, ] Frank Luna Page 6/7/006

6 Redo Eercise from Chapter using Equation 3 he idea here is to just epress the change of frame calculation b a matri equation, namel Equation 3 o change from frame A to frame B, we stick the frame A vectors, with coordinates relative to frame B in homogeneous coordinates, u, v, w, and O into the rows of a matri C hen, given the vector/point pa (,, z, w) that specifies a vector/point relative to a frame A, we obtain the same vector/point, identified b pb (,, z, w) relative to frame B, b performing the vector-matri multiplication: pb pc A From Eercise of Chapter, we have, in homogenous coordinates, the frame A vectors (relative to frame B): u (,,0,0), v (,,0,0), w ( 0, 0,, 0) A A hen the change of frame transformation ma be computed as follows: And, again in homogeneous coordinates, p (,, 0,) and q (,, 0, 0), O ( 6,, 0,) p B q B 0 0 0 0 0 6 0 0 0 3 6 [,, 0, ] (,, 0, ) 0 0 0 0 0 6 0 0 0 3 [,, 0, 0 ] (,, 0, 0) 7 Show that u u u3 v v v3 urow urowb AB u u u v v v u v v v u B [ ] 3 3 row col col col3 row u3 u3 u 33 v3 v3 v 33 u row3 urow3b his result shows that a matri-matri multiplication can be viewed as several linear combinations; specificall, in this case, the matri product AB is essentiall the three linear combinations u B, u B, and u 3B row row row Frank Luna Page 6/7/006

One wa to do this is to just do the matri multiplication brute force, but it is tedious even for small 3 3 matrices o make things simpler, we will onl calculate the ith row of AB, where i is arbitraril,, or 3 AB u v u v u v row i row i col row i col row i col3 v v v [ u u u ] v v v v v v u B 3 i i i3 3 row i 3 3 33 Now we just let i var over,, and 3 to obtain the result: u u u3 v v v3 urowb AB u u u v v v u B 3 3 row u3 u3 u 33 v3 v3 v 33 urow3b Chapter 3 ransformations; Planes Show that the -ais rotation transformation given b Equation 37 is a linear transformation Recall R ( u) (, cosθ zsin θ, sinθ + zcosθ) We must show that this transformation satisfies the linearit condition, which is Equation 3 (o save horizontal space, we will use column vector notation) Frank Luna Page 3 6/7/006

αu + βv R( αu+ βv) ( αu + βv) cosθ ( αuz + βvz) sinθ ( αu βv) sinθ ( αuz βvz) cosθ + + + αu + βv αu cosθ + βvcosθ αuzsinθ βvzsinθ αusinθ βvsinθ αuz cosθ βvzcosθ + + + αu βv αucosθ αuzsinθ+ βvcosθ βvzsinθ αusinθ + αuz cosθ βvsinθ βvzcosθ + u v α ucosθ uzsinθ+ β vcosθ vzsinθ usinθ uz cosθ vsinθ vz cosθ + + αr u + βr v We have shown R ( u ) to be a linear transformation Show that the identit function, defined b I ( u) u, is a linear transformation, and show that its matri representation is the identit matri, so the definition 3 of a linear We have I ( αu+ βv) αu+ βv α I( u) + β I( v) transformation is satisfied B appling the linear transformation to each of the basis vectors and then putting them into the rows of a matri, we obtain the matri representation of the identit function: I( i ) i 0 0 I( j) j 0 0 0 0 I( k ) k 3 Show that the row vectors in the -ais rotation matri R are orthonormal Recall R cosθ 0 sinθ 0 0 sinθ 0 cosθ Frank Luna Page 4 6/7/006

o show the row vectors are orthonormal, we must show the all are of unit length and that the are all mutuall orthogonal Let r ( cos θ, 0, sinθ ), r ( 0,, 0), and r3 ( sin θ, 0, cosθ ) be the row vectors of the matri R B the well known trig identit cos θ sin θ +, we have: r θ θ cos + 0 + sin r 0 + + 0 r3 sin θ + 0 + cos θ So all the row vectors are of unit length Now a straightforward application of the dot product shows: r r 0 r r3 0 r r3 0 hus the row vectors are all orthogonal to each other We have shown the row vectors to be orthonormal 4 Let R be the -ais rotation matri Show that the transpose of this matri is its inverse; that is, show R R R R I R cosθ 0 sinθ 0 0 sinθ 0 cosθ R R R R cosθ 0 sinθ cosθ 0 sinθ 0 0 0 0 0 0 0 0 I sinθ 0 cosθ sinθ 0 cosθ 0 0 cosθ 0 sinθ cosθ 0 sinθ 0 0 0 0 0 0 0 0 I sinθ 0 cosθ sinθ 0 cosθ 0 0 he inverse is unique so we must have R R 5 In 34, we showed how the -ais, -ais, and z-ais rotation matrices could be derived directl Another perspective is to think of these rotation matrices as special Frank Luna Page 5 6/7/006

cases of the arbitrar ais rotation matri Show that the arbitrar ais rotation matri reduces to the -ais, -ais, and z-ais rotation matrices when q equals, i, j, and k (ie, the standard basis vectors), respectivel We have ( ) ( ) ( ) ( ) ( ) ( ) ( ) + ( ) + ( ) c+ c c + zs z c s R c zs c c z c s z c s z c s c z c q + + aking q i (, 0, 0) to: ( c), we have in the above matri, z 0, and matri reduces c+ 0 0 0 0 R 0 c s 0 cosθ sinθ R i 0 s c 0 sinθ cosθ he process is analogous to obtain the -ais, and z-ais rotation matrices 6 Show that the translation matri affects points, but not vectors Using the definition of matri multiplication (Equation ), we have: 0 0 0 0 0 0,,, 0 0 0 b b bz z + b, + b, z+ bz, [ z ] and [,, z,0] ( z,,,) (,0,0, b), ( z,,,) ( 0,,0, b), ( z,,,) ( 0,0,, b), ( z,,,) ( 0,0,0,) 0 0 0 0 0 0 0 0 0 b b bz z ( z,,,0) (,0,0, b), ( z,,,0) ( 0,,0, b), ( z,,,0) ( 0,0,, b), ( z,,,0) ( 0,0,0,) [,, z,0] Frank Luna Page 6 6/7/006

7 Verif that the given scaling matri inverse is indeed the inverse of the scaling matri; that is, show, b directl doing the matri multiplication, that SS S S I Similarl, verif that the given translation matri inverse is indeed the inverse of the translation matri; that is, show, b directl doing the matri multiplication, that I SS S S s 0 0 0 0 0 0 0 0 0 s s s 0 0 0 s 0 s 0 0 0 0 0 0 0 0 0 0 0 s s I 0 0 s 0 z 0 0 0 sz 0 0 0 0 0 0 s z sz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 s s 0 0 0 s 0 0 0 s 0 0 0 s 0 s 0 0 0 s 0 0 0 0 0 0 0 0 s I 0 0 0 0 0 sz 0 sz 0 0 0 0 0 0 sz sz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I 0 0 0 0 0 0 0 0 0 0 0 0 b b bz b b bz b b b b bz bz 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 I 0 0 00 0 0 0 0 0 0 0 0 b b bz b b bz b b b b bz bz 0 0 0 0 0,, 0 these points define, 3, 6 8, 5, 3 8 Let p, p ( ), and p be three points Find the plane wo vectors on the plane are given b: u p p0 v p p 0 (, 3, 6) ( 0,, 0) (,, 6) ( 8, 5, 3) ( 0,, 0) ( 8, 4, 3) Now take the cross product to get a vector perpendicular to the plane (ie, the plane normal): Frank Luna Page 7 6/7/006

n u v (,, 6) ( 8, 4, 3) ( 8, 5, 0) d n p 0 5 Moreover, hen the plane consists of all the points p ( z,, ) satisf the equation: n ( p p 0) n p ( n p 0) 8+ 5 0z 5 0 that Remark: Because we didn t normalize the plane normal, the value d is no longer the signed distance from the origin, but some scaled distance 9 Let,,, 5 3 3 3 to the plane: ( 3 3,5 3,0 ), ( 3, 3, 3 ), and ( 3, 3, 0) π be a plane Define the localit of the following points relative he plane equation is: + + z 5 0 Plugging these points into the left-hand 3 3 3 side of the equation gives: 3 3 + 5 3 + 0 5 3 In front of the plane 3 3 3 3 + 3 + 3 5 0 On the plane 3 3 3 3 + 3 + 0 5 5 In back of the plane 3 3 3 0 Let,,, 5 3 3 3 π be a plane, and let r( t) (,, ) + t(,0,0) be a ra Find the point at which the ra intersects the plane hen write a short program using the D3DXPlaneIntersectLine (see the SDK documentation for the prototpe) function to verif our answer ( n p0 ) ( n u) ( 3 ) d 5 t 5 3+ ( 5 3 ) (,, ) ( 5 3 )(,0,0) (,, ) + ( 5 3 +, 0, 0) ( 5 3,, ) r + + + 3 We plug ( 5 3,, ) into the plane equation to verif it indeed lies on the plane: Frank Luna Page 8 6/7/006

5 3 + 5 0 On the plane 3 3 3 he code is given b: #include <d3d9h> #include <iostream> using namespace std; // Overload the "<<" operators so that we can use cout to // output D3DXVECOR3 objects ostream& operator<<(ostream& os, D3DXVECOR3& v) { os << "(" << v << ", " << v << ", " << vz << ")"; return os; } int main() { D3DXVECOR3 p0(-0f, 0f, -0f); D3DXVECOR3 u(0f, 00f, 00f); // Construct plane b specifing its (A, B, C, D) // components directl float s 0f / sqrtf(3); D3DXPLANE plane(s, s, s, -50f); // Function epects a line segment and not a ra; so we just // truncate our ra at p0 + 00*u to make a line segment D3DXVECOR3 isect; D3DXPlaneIntersectLine(&isect, &plane, &p0, &(p0 + 00*u)); cout << isect << endl; } return 0; he output is: (86605,, -) Press an ke to continue We note 5 3 86605, so the computer result agrees with our calculation Frank Luna Page 9 6/7/006