linear
• we will want to represent the geometry of points in space • we will often want to perform (rigid) transformations to these objects to position them – translate – rotate • or move them in an animation – time varying tform • position or move virtual camera • we also may use non-rigid tforms to specify shape – scale an object (uniform scale). – squash a sphere into an ellipsoid (non-unform scale. less often)
SO....
• so we must understand how to manipulate 3d coordinates and transforms • we must pay attention to order of tforms • we must pay attention to the role of the coordinate system w.r.t. which we perform a tform • we will look at linear and affine transformations • at end of the day, our code will have vertices with 3d coords and we will use 4 by 4 matrices to describe properly manipulate them • but to figure out what to code, we need to first do some thinking/paper-pencil work.
Geometric data types
• we describe a point using a coordinate vector
x y z
• specifies position wrt an agreed upon coordinate system – three agreed directions – agreed origin – if we change agreed upon c.s., we must change the coordinate vector • so a point is specified with a coordinate system and a coordinate vector
4 geometric data types
• point:p ˜ – represents place • vector: ~v – represents motion/offset/free arrow between 2 ordered points • coordinate vector: c • coordinate system ~st – “basis” for vectors – “frame” is for points
1 vectors vs coordinate vectors
• a point is a geometric entity in a 3D Euclidean space. – We will not present a formal mathematical definition of a point (This is a somewhat deep question) What is important is how points and lines in space “behave”. Not what they “are”. • a vector is a geometric entity, (motion/offset/free arrow between points), in a 3D Euclidean space • a coordinate vector is a set of numbers used to specify a vector given an agreed coordinate system vector space
• a set • has an addition operation • has a scalar multiplication with reals. • some other “special properies” – addition is associative and commutative – scalar mul must distribute across vector add
α(~v + ~w) = α~v + α ~w example vector spaces
• R3 (triplets of numbers) • quadratic functions, such as 5x2 + 2x − 7. – they can be added and scalar multiplied appropriately • this class: free-arrow between two ordered points in a euclidean space. – they can be added and scalar multiplied appropriately – these “vectors” should not be thought of as numerical objects. coordinate system: basis
• a basis is a minimal set of vectors that we can use to get to all of the vectors using our ops. – minimal == linearly independent • dimension is number of basis elements needed • for us it will be 3 • so basis can be used to address all of the vectors uniquely using coordinates
X ~ ~v = cibi i
• so a basis (a non-numerical object) can be used to represent a vector (non-numerical) with a set of coordinates (a numerical object!). shorthand
• write this as c1 X ~ h ~ ~ ~ i ~v = cibi = b1 b2 b3 c2 i c3
• rhs uses the “two finger rule” from linear algebra, but the experssion is mixed numeric/geometric.
2 – we will use two finger rule alot in what follows. • even shorter
~v = ~btc linear transformation
• a linear tform L maps from V to V • satisfies 2 rules
L(~v + ~u) = L(~v) + L(~u) L( ~αv) = αL(~v)
• we will use the notation ~v → L(~v) – book uses ⇒ linear tforms and matrices
• linear transformation can be exactly specified by telling us its effect on the basis vectors. • linear transforms can be expressed with matrix multiplication • Linearity implies
X ~ X ~ ~v → L(~v) = L( cibi) = ciL(bi) i i
• in our shorthand this is c1 c1 h ~ ~ ~ i h ~ ~ ~ i b1 b2 b3 c2 → L(b1) L(b2) L(b3) c2 c3 c3
~ • each L(bi) can ultimately be written as some linear combination of the original basis vectors using numbers Mi,j
h ~ ~ ~ i L(b1) L(b2) L(b3) = M1,1 M1,2 M1,3 h ~ ~ ~ i b1 b2 b3 M2,1 M2,2 M2,3 M3,1 M3,2 M3,3 so
• a linear transform operating on a vector can be expressed as c1 h ~ ~ ~ i b1 b2 b3 c2 c3
M1,1 M1,2 M1,3 c1 h ~ ~ ~ i → b1 b2 b3 M2,1 M2,2 M2,3 c2 M3,1 M3,2 M3,3 c3 well defined ops
• vector to vector
~btc → ~btMc
– see fig
3 • basis to basis,
h ~ ~ ~ i h ~ ~ ~ i b1 b2 b3 → L(b1) L(b2) L(b3)
• so this can be written as
~bt → ~btM
– see fig • coordinate vector to coordinate vector using two-finger rule. (this is the one we will see in code, but not until then).
c → Mc identity and inverse
• the identity matrix I implements to “do nothing” transform • an inverse matrix has the property MM −1 = M −1M = I • not every matrix has an inverse, but nice ones do, and all of our matrices are nice.
matrices for change of basis
• we just saw as an intermediate result an expression of the form ~a1 ~a2 ~a3 = M1,1 M1,2 M1,3 h ~ ~ ~ i b1 b2 b3 M2,1 M2,2 M2,3 M3,1 M3,2 M3,3
• or in shorthand
~at = ~btM ~atM −1 = ~bt
• this is not a transformation, but a statement of equality. • we have used a matrix to express one named basis with respect to another. • this will be useful too. • we can also use this to have different expressions for the same vector
~v = ~btc = ~atM −1c
• ex 2.1 and 2.2
Measurements
• we have some measurement operations that take in geometric objects and output numbers. • in a Euclidean space, we can measure the distances between point pairs, and the length k ~v k of a vector ~v. • in a Euclidean space, we can measure the angle θ made by two non-zero vectors ~v and ~w. • Given these, we can also define the (less intuitive) notion of a dot prodcut between two vectors:
~v · ~w = cos(θ) k ~v kk ~w k
• there are a bunch of “special properties” that this dot posseses, which we won’t go into. dot
4 • we can actually go the other way around. • once we have the dot product, we can use this to define length and angle.
k ~v k2:= ~v · ~v
~v · ~w cos(θ) := k ~v kk ~w k
• so in math we often think of the dot product as the core measurement. • indeed in math, one is allowed to come up with a new dot product as long as it satisfies the “special properties”, and then use that to come up with a new notion of length and angle. ortho
• 2 vectors are orthogonal if ~v · ~w = 0. • orthonormal basis • right handed (cyclically-ordered) basis • dot product in orthonormal basis
~ t ~ t X ~ X ~ b c · b d = ( cibi) · ( djbj) i j X X ~ ~ = cidj(bi · bj) i j X = cidi i
• so given an orthornormal coordinate system, we now have a nice numerical way to compute the dot product! – two cooridinate vectors in, one number out cross
• in 3d Euclidean space we also have a cross product on two ordered vectors. • the output is the vector
~v × ~w :=k v k k w k sin(θ) ~n
• where ~n is the right handed normal of {~v, ~w}
• in a r.h. o.n. basis, the coordinates of (~btc) × (~btd) are c2d3 − c3d2 c3d1 − c1d3 c1d2 − c2d1 rotations
• transform that preserves dot product between vector pairs • preserves right handedness between ordered vector triples • so maps r.h.o.n. basis to another • in 3d, every rotation fixes an axis, and rotates some angles r.h. about that axis. comments
• rotations about different axes do not commute
5 • composition of two rots about two axes is a rotation about some third axis. – though the identiy of this third axis is not obvious.
2D rotations
• rotate by θ degrees counter clockwise about the origin
h i x ~b ~b 1 2 y h i cos θ − sin θ x → ~b ~b 1 2 sin θ cos θ y
• and we can rotate the basis as h ~ ~ i b1 b2 h i cos θ − sin θ → ~b ~b 1 2 sin θ cos θ
3d rotations
• rotate a point by θ degrees around the z axis of the basis
x h ~ ~ ~ i b1 b2 b3 y z c −s 0 x h ~ ~ ~ i → b1 b2 b3 s c 0 y 0 0 1 z
• where c ≡ cosθ, and s ≡ sinθ. • fixes points on z axis • for points in z = k plane, it is like a 2D rotation • basis is important (z direction) more 3d rotations
• around x axis x h ~ ~ ~ i b1 b2 b3 y z 1 0 0 x h ~ ~ ~ i → b1 b2 b3 0 c −s y 0 s c z
• forward rotation around the y axis
c 0 s 0 1 0 −s 0 c arbitrary rotation
• can get any rotation by applying one x,y,z • can get any rotation by applying one x,y,x – called Euler angles
6 – visualize with set of gimbals
t • one can specify rotation with unit vector axis kˆ := [kx, ky, kz] and θ using matrix
2 kxv + c kxkyv − kzs kxkzv + kys 2 kykxv + kzs kyv + c kykzv − kxs 2 kzkxv − kys kzkyv + kxs kz v + c
• where v ≡ 1 − c other linear transforms
• uniform scales (common)
a 0 0 0 a 0 0 0 a
• non-uniform scales (used for modeling) ax 0 0 0 ay 0 0 0 az
• shears (rare)
1 b 0 0 1 0 0 0 1
• ex 2.3, 2.4
7