Docsity

Linear Transformations and Homogeneous Coordinates, Study notes of Computer Graphics

Partial preview of the text

Download Linear Transformations and Homogeneous Coordinates and more Study notes Computer Graphics in PDF only on Docsity!

Homogeneous Transformations

CSE167: Computer Graphics Instructor: Steve Rotenberg UCSD, Fall 2005

Example: Distance Between Lines

 We have two non-intersecting 3D lines in space  (^) Line 1 is defined by a point p 1 on the line and a ray r 1 in the direction of the line, and line 2 is defined by p 2 and r 2  Find the closest distance between the two lines p 1 p 2 r 1 r 2

Example: Distance Between Lines

 (^) Notice that the sign of the result might be positive or negative depending on the geometric configuration, so we should really take the absolute value if we want a positive distance  (^) Also note that the equation could fail if | r 1 x r 2 |=0, implying that the lines are parallel. We should really test for this situation and use a different equation if the lines are parallel ( ) ( ) 1 2 2 1 1 2

r r

p p r r

×

− ⋅ ×

dist =

Linear Transformations

v ′= M ⋅ v + d

3 2 1 3 3 3 2 2 2 1 1 1 3 3 3 3 2 2 2 2 1 1 1 1 d d d v v v a b c a b c a b c v v v v a v b v c v d v a v b v c v d v a v b v c v d z y x z y x z x y z y x y z x x y z

Matrix Dot Matrix

L = M ⋅ N

31 32 33 21 22 23 11 12 13 31 32 33 21 22 23 11 12 13 31 32 33 21 22 23 11 12 13

n n n

n n n

n n n

m m m

m m m

m m m

l l l

l l l

l l l

12 11 12 12 22 13 32

l = m n + m n + m n

Multiple Rotations & Scales

 We can combine a sequence of rotations and scales into a single matrix  For example, we can combine a y-rotation, followed by a z-rotation, then a non-uniform scale, and finally an x-rotation:

v M v

M R S s R R

x z y

Combining Transformations

We see that we can combine a sequence

of rotations and/or scales

We can also combine a sequence of

translations

But what if we want to combine

translations with rotations/scales?

Homogeneous Transformations

3 3 3 3 2 2 2 2 1 1 1 1 3 3 3 3 2 2 2 2 1 1 1 1 = + + +

x y z z x y z y x y z x x y z z y x z y x v v v v a v b v c v d v a v b v c v d v a v b v c v d v v v a b c d a b c d a b c d v v v v M v

Homogeneous Transformations

 For example, a translation by vector r followed by a z -axis rotation can be represented as: 

sin cos 0 0 cos sin 0 0 1 z y x z y x z y x v v v r r r v v v θ θ θ θ

Rotation Matrices

            − = 0 0 0 1 sin 0 cos 0 0 1 0 0 cos 0 sin 0 θ θ θ θ θ y R

            − = 0 0 0 1 0 sin cos 0 0 cos sin 0 1 0 0 0 θ θ θ θ θ x

R ( )

            − = 0 0 0 1 0 0 1 0 sin cos 0 0 cos sin 0 0 θ θ θ θ θ z R

Euler’s Theorem

 Euler’s Theorem: Any two independent orthonormal coordinate frames can be related by a sequence of rotations (not more than three) about coordinate axes, where no two successive rotations may be about the same axis.  (^) Not to be confused with Euler angles, Euler integration, Newton-Euler dynamics, inviscid Euler equations, Euler characteristic…  (^) Leonard Euler (1707-1783)

Euler’s Theorem

 There are two useful ways of looking at Euler’s theorem in relationship to orientations:

  1. It tells us that we can represent any orientation as a rotation about three axes, for example x, then y, then z
  2. It also tells us that any orientation can be represented as a single rotation about some axis by some angle

Orientation

 (^) One method for storing an orientation is to simply store it as a sequence of rotations about principle axes, such as x, then y, then z. We refer to this as Euler angles. This is a compact method, as it uses exactly 3 numbers to store the orientation  (^) Another option is to represent the orientation as a unit length axis and a scalar rotation angle, thus using 4 numbers in total. This is a conceptually straightforward method, but is of limited mathematical use, and so is not terribly common  (^) A third option is to use a 3x3 matrix to represent orientation (or the upper 3x3 portion of a 4x4 matrix). This method uses 9 numbers, and so must contain some extra information (namely, the scaling and shearing info)  (^) A fourth option is to use a quaternion, which is a special type of 4- dimensional vector. This is a popular and mathematically powerful method, but a little bit strange… These are covered in Math155B and CSE  (^) No matter which method is used to store the orientation information, we usually need to turn it into a matrix in order to actually transform points or do other useful things

Scale Transformations

 (^) The uniform scaling matrix scales an entire object by scale factor s  (^) The non-uniform scaling matrix scales independently along the x , y , and z axes

            = 0 0 0 1 0 0 0 0 0 0 0 0 0 s s s s u S

            = 0 0 0 1 0 0 0 0 0 0 0 0 0 z y x n s s s S s