Title: Geometry (Many slides adapted from Octavia Camps and Amitabh Varshney)
1Geometry(Many slides adapted from Octavia Camps
and Amitabh Varshney)
2Goals
- 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
3Vectors
- Ordered set of numbers (1,2,3,4)
- Example (x,y,z) coordinates of pt in space.
4Vector Addition
Vw
v
w
5Scalar Product
av
v
6Inner (dot) Product
The inner product is a SCALAR!
7How do we prove these properties of the inner
product? Lets start with the fact that
orthogonal vectors have 0 inner product. Suppose
one vector is (x,y), and WLOG x,ygt0. Then, if we
rotate that by 90 degrees counterclockwise, well
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 vw (vw)/(vw) vw
This means that if we can show that when v and w
are unit vectors vw cos alpha, then it will
follow that in general vw v w cos
alpha. So suppose v and w are unit
vectors. Next, note that if w1 w2 w, then vw
v(w1w2) vw1 vw2. For any w, we can
write it as the sum of w1w2, where w1 is
perpendicular to v, and w2 is in the same
direction as v. So vw1 0. vw2 w2,
since vw2/w2 1. Then, if we just draw a
picture, we can see that cos alpha w2
vw2 vw.
8Points
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)
9Lines
- Line y mx a
- Line sum of a point and a vector
- P P1 ad
- (whered is a column vector)
- Line Affine sum of two points
- P a1P1 a2P2, where a1 a2 1
-
- Line Segment For 0 a1, a2 1, P lies
between P1 and P2 - Line set of points equidistant from the origin
in the direction of a unit vector. -
d
P1
P2
P1
10Plane and Triangle
- Plane sum of a point and two vectors
- P P1 au b v
- Plane set of points equidistant
- from origin in direction
- of a vector.
- Triangle Affine sum of three points
- with ai ³ 0
- P a1P1 a2P2 a3P3,
- where a1 a2 a3 1
- P lies between P1, P2, P3
-
v
u
P1
P3
P2
P1
11Generalizing ...
- Affine Sum of arbitrary number of points
Convex Hull - P a1P1 a2P2 anPn, where a1 a2
an 1 and ai ³ 0
12Normal of a Plane
- Plane sum of a point and two vectors
- P P1 au bv
- P - P1 au bv
- Ifn is orthogonal tou andv (n u v )
- n T (P - P1) an T u bn T v 0
13Implicit Equation of a Plane
- n T (P - P1) 0
- a x
x1 - Letn b P y P1 y1
- c z
z1 - Then, the equation of a plane becomes
- a (x - x1) b (y - y1) c (z - z1) 0
- a x b y c z d 0
- Thus, the coefficients of x, y, z in a plane
equation define the normal.
n
v
u
P1
14Normal of a Triangle
- Normal of the plane containing the triangle (P1,
P2 , P3 ) - n (P2 - P1) (P3 - P1)
P3
P2
Normal pointing towards you
Normal pointing away from you
P1
P2
P1
P3
- 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
nv (n1 n2 nk) / k åni / k
average of adjacent triangle normals or
better nv å (Ai ni) / (k å (Ai) )
area-weighted average of adjacent triangle
normals
16Geometry Continued
- Much of last classes material in Appendix A
17Matrices
Sum
A and B must have the same dimensions
18Matrices
Product
A and B must have compatible dimensions
Identity Matrix
19Matrices
- Associative T(U(Vp)) (TUV)p
- Distributive T(uv) Tv Tv
20Matrices
Transpose
If
A is symmetric
21Matrices
Determinant
A must be square
22Matrices
Inverse
A must be square
23Euclidean transformations
242D Translation
P
t
P
252D Translation Equation
262D Translation using Matrices
P
27Scaling
P
P
28Scaling Equation
P
s.y
P
y
x
s.x
29Rotation
P
P
30Rotation Equations
Counter-clockwise rotation by an angle ?
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 its in the
same position relative to the rotated coordinates
that it was in before rotation relative to the x,
y coordinates. That is, its rotated.
32Degrees of Freedom
R is 2x2
4 elements
BUT! There is only 1 degree of freedom ?
The 4 elements must satisfy the following
constraints
33Transformations 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?
34Rotation and Translation
)
(
)
(
x
y
1
cos q -sin q tx
sin q cos q ty
0 0 1
Rotation, Scaling and Translation
)
(
)
(
x
y
1
a -b tx
b a ty
0 0 1
35Rotation 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.
36Stretching Equation
P
Sy.y
P
y
x
Sx.x
37Stretching tilting and projecting(with weak
perspective)
38Linear Transformation
SVD
39Affine Transformation
40Viewing Position
- Express world in new coordinate system.
- If origins same, this is done by taking inner
product with new coordinates. - Otherwise, we must translate.
41Suppose, 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)
42Simple 3D Rotation
Rotation about z axis. Rotates x,y coordinates.
Leaves z coordinates fixed.
43Full 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.
453D Rotation Translation
46Transformation of lines/normals
- 2D. Line is set of points (x,y) for which
(x,y).(ab)T0. Suppose we rotate points by R.
We want a matrix, T, so that - R(x,y) .T
473D Viewing Position
- Rows of rotation matrix correspond to new
coordinate axis.
48Rotation 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.