Download presentation
Presentation is loading. Please wait.
1
Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
2
Goals Represent points, lines and triangles as column vectors. Represent motion as matrices. Move geometric objects with matrix multiplication. Refresh memory about geometry and linear algebra
3
Vectors Ordered set of numbers: (1,2,3,4) Example: (x,y,z) coordinates of pt in space.
4
Vector Addition v w V+w
5
Scalar Product v av
6
Inner (dot) Product v w The inner product is a SCALAR!
7
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.
8
Points Using 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)
9
Lines Line: y = mx + a Line: sum of a point and a vector P = P 1 + d (where d is a column vector) Line: Affine sum of two points P = P 1 + P 2, where + = 1 Line Segment: For 0 , 1, P lies between P 1 and P 2 Line: set of points equidistant from the origin in the direction of a unit vector. P1P1 dd P1P1 P2P2
10
Plane and Triangle Plane: sum of a point and two vectors P = P 1 + u + v Plane: set of points equidistant from origin in direction of a vector. Triangle: Affine sum of three points with i 0 P = P 1 + P 2 + P 3, where + + = 1 P lies between P 1, P 2, P 3 P1P1 uu vv P1P1 P2P2 P3P3
11
Generalizing... Affine Sum of arbitrary number of points: Convex Hull P = P 1 + P 2 + … + n P n, where + + … + n = 1 and i 0
12
Normal of a Plane Plane: sum of a point and two vectors P = P 1 + u + v P - P 1 = u + v If n is orthogonal to u and v (n = u v ) : n T P - P 1 ) = n T u + n T v = 0 P1P1 uu vv uu P1P1 vv nn
13
Implicit Equation of a Plane n T P - P 1 ) = 0 a x x 1 Let n = b P = y P 1 = y 1 c z z 1 Then, the equation of a plane becomes: a (x - x 1 ) + b (y - y 1 ) + c (z - z 1 ) = 0 a x + b y + c z + d = 0 Thus, the coefficients of x, y, z in a plane equation define the normal. P1P1 uu vv uu P1P1 vv nn
14
Normal of a Triangle Normal of the plane containing the triangle ( P 1, P 2, P 3 ): n = ( P 2 - P 1 ) ( P 3 - P 1 ) P1P1 P2P2 nn P3P3 P1P1 P2P2 P3P3 P1P1 P3P3 P2P2 Normal pointing towards youNormal 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.
15
Normal of a Vertex in a Mesh n1n1 n2n2 n3n3 nknk nvnv n v = ( n 1 + n 2 + … + n k ) / k = n i / k = average of adjacent triangle normals or better: n v = i n i ) / ( k i ) ) = area-weighted average of adjacent triangle normals
16
Geometry Continued Much of last classes’ material in Appendix A
17
Matrices Sum: A and B must have the same dimensions
18
Matrices Product: A and B must have compatible dimensions Identity Matrix:
19
Matrices Associative T*(U*(V*p)) = (T*U*V)*p Distributive T*(u+v) = T*v + T*v
20
Matrices Transpose: If A is symmetric
21
Matrices Determinant: A must be square
22
Matrices Inverse: A must be square
23
Euclidean transformations
24
2D Translation t P P’
25
2D Translation Equation P x y txtxtxtx tytytyty P’ t
26
2D Translation using Matrices P x y txtxtxtx tytytyty P’ t tP
27
Scaling P P’
28
Scaling Equation P x y s.x P’ s.y
29
Rotation P P’
30
Rotation Equations Counter-clockwise rotation by an angle P x Y’ P’ X’ y
31
Why does multiplying points by R rotate them? Think of the rows of R as a new coordinate system. Taking inner products of each points with these expresses that point in that coordinate system. This means rows of R must be orthonormal vectors (orthogonal unit vectors). Think of what happens to the points (1,0) and (0,1). They go to (cos theta, -sin theta), and (sin theta, cos theta). They remain orthonormal, and rotate clockwise by theta. Any other point, (a,b) can be thought of as a(1,0) + b(0,1). R(a(1,0)+b(0,1) = Ra(1,0) + Ra(0,1) = aR(1,0) + bR(0,1). So it’s in the same position relative to the rotated coordinates that it was in before rotation relative to the x, y coordinates. That is, it’s rotated.
32
Degrees of Freedom R is 2x2 4 elements BUT! There is only 1 degree of freedom: The 4 elements must satisfy the following constraints:
33
Transformations can be composed Matrix multiplication is associative. Combine series of transformations into one matrix. (example, whiteboard). In general, the order matters. (example, whiteboard). 2D Rotations can be interchanged. Why?
34
Rotation and Translation cos -sin tx sin cos ty 001 ( ) ( x y 1 ) a-btx baty 001 ( ) ( x y 1 ) Rotation, Scaling and Translation
35
Rotation about an arbitrary point Can translate to origin, rotate, translate back. (example, whiteboard). This is also rotation with one translation. –Intuitively, amount of rotation is same either way. –But a translation is added.
36
Stretching Equation P x y S x.x P’ S y.y
37
Stretching = tilting and projecting (with weak perspective)
38
Linear Transformation SVD
39
Affine Transformation
40
Viewing Position Express world in new coordinate system. If origins same, this is done by taking inner product with new coordinates. Otherwise, we must translate.
41
Suppose, for example, we want to have the y axis show how we are facing. We want to be at (7,3), facing in direction (ct,st). The x axis must be orthogonal, (-st,ct). If we want to express (x,y) in this coordinate frame, we need to take: (ct,st)*(x- 7,y-3), and (-st,ct)*(x-7,y-3). This is done by multiplying by matrix with rows (-st,ct) and (ct,st)
42
Simple 3D Rotation Rotation about z axis. Rotates x,y coordinates. Leaves z coordinates fixed.
43
Full 3D Rotation Any rotation can be expressed as combination of three rotations about three axes. Rows (and columns) of R are orthonormal vectors. R has determinant 1 (not -1).
44
Intuitively, it makes sense that 3D rotations can be expressed as 3 separate rotations about fixed axes. Rotations have 3 degrees of freedom; two describe an axis of rotation, and one the amount. Rotations preserve the length of a vector, and the angle between two vectors. Therefore, (1,0,0), (0,1,0), (0,0,1) must be orthonormal after rotation. After rotation, they are the three columns of R. So these columns must be orthonormal vectors for R to be a rotation. Similarly, if they are orthonormal vectors (with determinant 1) R will have the effect of rotating (1,0,0), (0,1,0), (0,0,1). Same reasoning as 2D tells us all other points rotate too. Note if R has determinant -1, then R is a rotation plus a reflection.
45
3D Rotation + Translation Just like 2D case
46
Transformation of lines/normals 2D. Line is set of points (x,y) for which (x,y).(ab) T =0. Suppose we rotate points by R. We want a matrix, T, so that: R*(x,y).T
47
3D Viewing Position Rows of rotation matrix correspond to new coordinate axis.
48
Rotation about a known axis Suppose we want to rotate about u. Find R so that u will be the new z axis. –u is third row of R. –Second row is anything orthogonal to u. –Third row is cross-product of first two. –Make sure matrix has determinant 1.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.