1Geometry(Many slides adapted from Octavia Camps and Amitabh Varshney)Much of material in Appendix A2Goals• Represent points, lines and triangles as column vectors.• Represent motion as matrices.• Move geometric objects with matrix multiplication. • Refresh memory about geometry and linear algebra3Vectors• Ordered set of numbers: (1,2,3,4)• Example: (x,y,z) coordinates of pt in space.runit vecto a is ,1 If),(12,,21vvxvxxxvniin 4Vector Addition),(),(),(22112121yxyxyyxxwvvvwwV+wV+w5Scalar Product),(),( 2121axaxxxaavvvavav6Inner (dot) Productvvww22112121.),).(,(. yxyxyyxxwvThe inner product is a The inner product is a SCALAR!SCALAR!cos||||||||),).(,(. 2121wvyyxxwvwvwv 0.7First, we note that if we scale a vector, we scale its inner product. That is, <sv,w> = s<v,w>. This follows pretty directly from the definition.So from now on, we can assume that w, and maybe v are unit vector. Then, as an example, we can consider the case where w = (1,0). It follows from the definition of cosine that <v,w> = ||v||cos(alpha). We can also see that taking <v,(1,0)> and <v,(0,1)> produces the (x,y) coordinates of v. That is, if (1,0) and (0,1) are an orthonormal basis, taking inner products with them gives the coordinates of a point relative to that basis. This is why the inner product is so useful. We just have to show that this is true for any orthonormal basis, not just (1,0) and (0,1).How do we prove these properties of the inner product? Let’s start with the fact that orthogonal vectors have 0 inner product. Suppose one vector is (x,y), and WLOG x,y>0. Then, if we rotate that by 90 degrees counterclockwise, we’ll get (y, -x). Rotating the vector is just like rotating the coordinate system in the opposite direction. And (x,y)*(y,-x) = xy – yx = 0.Next, note that v*w = (v*w)/(||v||||w||) * ||v||||w|| This means that if we can show that when v and w are unit vectors v*w = cos alpha, then it will follow that in general v*w = ||v|| ||w|| cos alpha. So suppose v and w are unit vectors.Next, note that if w1 + w2 = w, then v*w = v*(w1+w2) = v*w1 + v*w2. For any w, we can write it as the sum of w1+w2, where w1 is perpendicular to v, and w2 is in the same direction as v. So v*w1 = 0. v*w2 = ||w2||, since v*w2/||w2|| = 1. Then, if we just draw a picture, we can see that cos alpha = ||w2|| = v*w2 = v*w.8PointsUsing these facts, we can represent points. Note:(x,y,z) = x(1,0,0) + y(0,1,0) + z(0,0,1)x = (x,y,z).(1,0,0) y = (x,y,z).(0,1,0)z = (x,y,z).(0,0,1)9Lines• Line: y = mx + a• Line: sum of a point and a vectorP = P1+ d(whered is a column vector)• Line: Affine sum of two pointsP = P1+ P2, where + = 1Line Segment: For 0 , 1, P lies between P1and P2• Line: set of points equidistant from the origin in the direction of a unit vector. (a,b).(x,y) = -c.P1dP1P210Plane and Triangle• Plane: sum of a point and two vectorsP = P1+ u + vPlane: set of points equidistant from origin in direction of a vector.• Triangle: Affine sum of three points with i0P = P1+ P2+ P3, where + + = 1P lies between P1, P2, P3P1uvP1P2P311Generalizing ...Affine Sum of arbitrary number of points: Convex HullP = P1+ P2+ … + nPn, where + + … +n = 1 and i012Normal of a PlanePlane: sum of a point and two vectorsP = P1+ u + vP - P1= u + vIfn is orthogonal tou andv (n =uv ) :nT P - P1) = n Tu + n Tv = 0P1 u v uP1 v n13Implicit Equation of a Planen T P - P1) = 0a x x1Letn = b P = y P1= y1c z z1Then, the equation of a plane becomes:a (x - x1) + b (y - y1) + c (z - z1) = 0a x + b y + c z + d = 0Thus, the coefficients of x, y, z in a plane equation define thenormal.P1 u v uP1 v n14Normal of a TriangleNormal of the plane containing the triangle (P1, P2, P3):n = (P2- P1) (P3- P1) P1P2 nP3P1P2P3P1P3P2Normal pointing towards you Normal pointing away from you• Models constructed with consistent ordering of triangle vertices :all clockwise or all counter-clockwise. • Usually normals point out of the model.15Normal of a Vertex in a Mesh n1 n2 n3 nk nv nv= (n1 +n2 + … +nk) / k = ni/ k= average of adjacent triangle normalsor better: nv= i ni) / (k i) ) = area-weighted average of adjacent triangle
View Full Document