homogeneous transform

Upload: aaqib-khan

Post on 03-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Homogeneous Transform

    1/10

    Transformations in Homogeneous Coordinates(Com S 477/577 Notes)

    Yan-Bin Jia

    Sep 3, 2013

    1 Homogeneous Transformations

    A projective transformation of the projective plane is a mapping L : P 2 P 2 dened asuvw

    a b cd e f g h k

    uvw

    =au + bv + cwdu + ev + fwgu + hv + kw

    , (1)

    where a,b, c, d, e, f ,g,h,k R . The 3 3 matrix representing the mapping L of the projectiveplane is called a homogeneous transformation matrix . When g = h = 0 and k = 0, the mapping Lis an affine transformation introduced in the previous lecture. Affine transformations correspondto transformations of the Cartesian plane.

    Note that homogeneous coordinates ( ru,rv,rw ) under the mapping (1) has image

    aru + brv + crwdru + erv + f rwgru + hrv + krw

    .

    A division by r gives the image L(u,v,w ) of (u,v,w ). Thus L(ru,rv,rw ) and L(u,v,w ) are equiv-alent and correspond to the same point in homogeneous coordinates. Therefore the denition of atransformation does not depend on the choice of homogeneous coordinates for a given point.

    A transformation of the projective space is a mapping M : P 3 P 3 given bysuvw

    m11 m12 m13 m14m21 m22 m23 m24m31 m32 m33 m34m41 m42 m43 m44

    suvw

    .

    The 4

    4 matrix ( m ij ) is called the homogeneous transformation matrix of M . If the matrix is non-

    singular, then M is called a non-singular transformation. If m41 = m42 = m43 = 0 and m44 = 0,then M is said to be an affine transformation . Affine transformations correspond to translations,scalings, rotations, reections, etc. of the three-dimensional space.

    1

  • 8/12/2019 Homogeneous Transform

    2/10

    1.1 Translation and Scaling

    We rst describe the homogeneous transformation matrices for translations and scalings, in theplane and the space. Let us start with translation:

    Trans( h, k ) =

    1 0 h

    0 1 k0 0 1 .

    Then 1 0 h0 1 k

    0 0 1

    xy1

    =x + hy + k

    1,

    which veries that the point ( x, y) is translated to ( x + h, y + k).A translation by a, b, c in the x-, y-, and z-directions, respectively, has the transformation

    matrix:

    Trans( a,b,c) =

    1 0 0 a0 1 0 b

    0 0 1 c0 0 0 1

    .

    The point p = ( x,y,z, 1) is translated to the point

    p = Trans( a,b,c) p

    =

    1 0 0 a0 1 0 b0 0 1 c0 0 0 1

    xyz1

    =

    x + ay + b

    z + c1

    .

    Accordingly, the point ( x,y,z ) in the Cartesian space is translated to ( x + a, y + b, z + c).The homogeneous scaling matrix is

    Scale(sx , s y ) =sx 0 00 sy 00 0 1

    .

    Then sx 0 00 sy 0

    0 0 1

    xy

    1

    =sx xsy y

    1

    .

    Example 1. The unit square with vertices (1 , 1), (2, 1), (2 , 2), and (1 , 2) is scaled about the origin by factorsof 4 and 2 in the x- and y- directions, respectively. We have

    4 0 00 2 00 0 1

    1 2 2 11 1 2 21 1 1 1

    =4 8 8 42 2 4 41 1 1 1

    .

    2

  • 8/12/2019 Homogeneous Transform

    3/10

    So the image is a square with vertices (4 , 2), (8, 2), (8, 4), and (4 , 4).

    A scaling about the origin by factors sx /s w , sy /s w , and sz /s w in the x-, y-, and z-directions,respectively, has the transformation matrix (often, sw is chosen to be 1):

    Scale(sx , s y , s z , sw ) =

    sx 0 0 0

    0 sy 0 00 0 sz 00 0 0 sw

    .

    Similar to the cases of translation and scaling, the transformation matrix for a planar rotationabout the origin through an angle is

    Rot( ) =cos sin 0sin cos 0

    0 0 1.

    1.2 Rotation about a Point

    A rotation through an angle about a point ( a, b) is obtained by performing a translation whichmaps ( a, b) to the origin, followed by a rotation through an angle about the origin, and followedby a translation which maps the origin to ( a, b). The rotation matrix is

    Rot (a,b ) () = Trans( a, b)Rot( ) Trans( a, b)

    =1 0 a0 1 b0 0 1

    cos sin 0sin cos 00 0 1

    1 0 a0 1 b0 0 1

    =cos sin a cos + bsin + asin cos a sin bcos + b

    0 0 1

    . (2)

    Example 2. A square has vertices p 1 = (1 , 1), p 2 = (2 , 1), p 3 = (2 , 2), and p 4(1, 2). Determine the newvertices of the square after a rotation about p 2 through an angle of / 4. The transformation matrix is

    1 32

    1

    2

    3

    p2 , p2

    p4

    p4

    p3 p3

    p1

    p1

    Figure 1 : Rotation about p2 .

    Rot (2 , 1) (/ 4) =

    22

    22 2

    22

    22

    22 3

    22 + 1

    0 0 1

    .

    Apply the transformation above to the homogeneous coordinates of thevertices:

    22 22 2 22 22

    22 3

    22 + 1

    0 0 1

    1 2 2 11 1 2 21 1 1 1

    =2 22 2 2 22 2 21

    22 1 1 +

    22 1

    1 1 1 1

    1.2929 2 1.2929 0.58580.2929 1 1.7071 1

    1 1 1 1

    3

  • 8/12/2019 Homogeneous Transform

    4/10

    Thus the new vertices are p 1 (1.2929, 0.2929), p 2 = (2 , 1), p 3 (1.2929, 1.7071), and p 4 (0.5858, 1.0),as illustrated in Figure 1.

    2 Inverse Transformations

    The identity transformation I is the transformation that leaves all points of the plane unchanged.More precisely, I is the transformation for which I L = L I = L, for any planar transformationL. The transformation matrix of the identity transformation in homogeneous coordinates is the3 3 identity matrix I 3.The inverse of a transformation L, denoted L 1, maps images of L back to the original points.More precisely, the inverse L 1 satises that L 1 L = L L

    1 = I .

    Lemma 1 Let T be the matrix of the homogeneous transformation L. If the inverse transformation L 1 exists, then T 1 exists and is the transformation matrix of L 1 . Conversely, if T 1 exists,then the transformation represented by T 1 is the inverse transformation of L.

    Proof Suppose L has an inverse L 1 with transformation matrix R. The concatenations L

    L 1

    and L 1 L must be identity transformations. Accordingly, the transformation matrices T R andRT are equal to I 3. Thus R is the inverse of matrix T , that is, R = T 1.Conversely, suppose the matrix T has an inverse T 1, which denes a transformation R. Since

    T 1T = T T 1 = I 3, it follows that R L and L R are the identity transformation. By denition,R is the inverse transformation.We easily obtain the inverses of translation, rotation, and scaling:

    Trans( h, k ) 1 = Trans( h, k),Rot( ) 1 = Rot( ),

    Scale(s1, s2) 1 = Scale(1 /s 1, 1/s 2).

    A transformation L : P 2 P 2 with an inverse L 1 is called a non-singular transformation .

    Lemma 1 implies that a transformation is non-singular if and only if its transformation matrix isnon-singular. Non-singular matrices A and B satises (AB ) 1 = B 1A 1.

    In homogeneous coordinates, the concatenation of transformations T 1 and T 2, denoted T 2 T 1 ,can be carried out with matrix multiplications alone. For example, a rotation Rot( ) about theorigin followed by a translation Trans( h, k ) followed by a scaling Scale(sx , s y ) has the homogeneoustransformation matrix

    Scale(sx , s y ) Trans( h, k ) Rot( ) =sx 0 00 sy 00 0 1

    1 0 h0 1 k0 0 1

    cos sin 0sin cos 00 0 1

    =sx cos sx sin sx hsy sin sy cos sy k

    0 0 1

    Example 3. Determine the transformation matrix of the inverse of the concatenation of transformationsTrans( 2, 5) Rot( / 3). The transformation matrix L1 of the inverse is the inverse of the corresponding

    4

  • 8/12/2019 Homogeneous Transform

    5/10

    matrix product:

    L1 = Trans( 2, 5) Rot( / 3)1

    = Rot( / 3)1 Trans( 2, 5)1= Rot( / 3) Trans(2 ,

    5)

    =

    12 32 1 + 5 32 3

    212 52 + 3

    0 0 1

    .

    3 Reection in an Arbitrary Line

    How to determine the transformation matrix for reection in an arbitrary line ax + by + c = 0? If c = 0 and either a = 0 or b = 0, then it is the reection in either x- or y-axis that we consideredbefore. The matrix is

    1 0 00 1 00 0 1 or 1 0 00 1 0

    0 0 1. (3)

    In general, the reection is obtained by transforming the line to one of the axes, reecting inthat axis, and then taking the inverse of the rst transformation. Suppose b = 0. More specically,the reection is accomplished in the following ve steps:

    1. The line intersects the y-axis in the point (0 , c/b ).2. Make a translation that maps (0 , c/b ) to the origin.3. The slope of the line is tan = a/b , where the angle made by the line with the x-axis

    remains the same after the translation. Rotate the line about the origin through an angle. This maps the line to the x-axis.

    4. Apply a reection in the x-axis.

    5. Rotate about the origin by and then translate by (0 , c/b).The concatenation of the above transformation is

    1 0 00 1 c/b0 0 1

    cos sin 0sin cos 00 0 1

    1 0 00 1 00 0 1

    cos sin 0

    sin cos 00 0 11 0 00 1 c/b0 0 1

    =cos2

    sin2 2sin cos 2c

    b sin cos

    2sin cos sin2 cos2 2cb cos2 0 0 1

    .

    Since tan = a/b , it follows that cos 2 = 1/ (1 + tan 2 ) = b2/ (a2 + b2) and sin 2 = 1 cos2 =a2/ (a2 + b2). So sin cos = tan cos2 = ab/ (a2 + b2). Substituting these expressions into (4)

    5

  • 8/12/2019 Homogeneous Transform

    6/10

    yieldsb2 a 2

    a 2 + b2 2aba 2 + b2 2aca 2 + b2 2aba 2 + b2 a

    2 b2

    a 2 + b2 2bca 2 + b20 0 1

    .

    In homogeneous coordinates, multiplication by a factor does not change the point. So the abovematrix can be scaled by a factor a2 + b2 to remove all the denominators in the entries, yielding thereection matrix

    Ref (a,b,c ) =b2 a2 2ab 2ac2ab a2 b2 2bc0 0 a2 + b2

    .

    Note that the above matrix agrees with (3) in the cases of reection in x- and y-axes. Thus wehave removed the assumption b = 0 made for deriving the reection matrix.

    4 Application 1 Instancing

    door

    Figure 2 : Front of a house ob-tained from instances of square andpoint.

    A geometric object is created by dening its components. Forexample, the front of a house in Figure 2 consists of rectangles,which form the walls, windows, and door of the house. The rect-angles are scaled from a square, which is an example of a picture element . For convenience, picture elements are dened in theirown local coordinate systems, and are constructed from graphical primitives which are the basic building blocks. Picture elementsare dened once but may be used many times in the constructionof objects.

    For example, a square with vertices (0 , 0), (1, 0), (1, 1), and(0, 1) can be obtained using the graphical primitive Line for the

    line segment joining the points (0 , 0) and (1 , 0) through rotationsand translations. A transformed copy of a graphical primitiveor picture element is referred to as an instance. The aforementioned square, denoted Square , isdened by four instances of the line.

    The completed real object is dened in world coordinates by applying a transformation toeach picture element. The house in the gure is dened by six instances of the picture elementSquare , and one instance of the primitive Point (for the door handle). In particular, the frontdoor is obtained from Square by applying a scaling of 0.5 unit in the x-direction, followed by atranslation of 3 units in the x-direction and 1 unit in the y-direction. In homogeneous coordinates,the transformation matrix is given by

    Trans(3 , 1) Scale(0.5, 1) =1 0 30 1 10 0 1

    0.5 0 00 1 00 0 1

    =0.5 0 3

    0 1 10 0 1

    .

    The vertices of the door are obtained by applying the above transformation matrix to the vertices

    6

  • 8/12/2019 Homogeneous Transform

    7/10

    of the Square primitive, giving

    0.5 0 30 1 10 0 1

    0 1 1 00 0 1 11 1 1 1

    =3 3.5 3.5 31 1 2 21 1 1 1

    .

    So the vertices of the door in world coordinates are (3 , 1), (3.5, 1), (3.5, 2), and (3 , 2).

    5 Rotation in Space

    Like a rotation in the plane, a rotation in the space takes about a line referred to as its rotation axis .Any rotation can be decomposed into three primary rotations about the x-, and y-, and z-axes:

    Rot x (x ) =

    1 0 0 00 cosx sin x 00 sin x cosx 00 0 0 1

    ,

    Rot y (y ) =cos y 0 siny 0

    0 1 0 0

    sin y 0 cosy 00 0 0 1,

    Rot z (z ) =

    cos z sin z 0 0sin z cosz 0 00 0 1 00 0 0 1

    .

    Figure 3(a) shows the direction in which the primary rotations take when the rotation angleis positive. Figure 3(b) is a mnemonic that helps to remember the directions. For instance, the

    x

    z

    y

    x

    y

    z x

    y z

    (a) (b)

    Figure 3 : Rotations about the coordinate axes.

    positive sense of a rotation about the y-axis has the effect of moving points on the z-axis towardthe x-axis.

    7

  • 8/12/2019 Homogeneous Transform

    8/10

    Example 4. A rotation through an angle / 6 about the y-axis followed by a translation by 1, 1, 2respectively along the x-, y-, and z-axes has the transformation matrix

    Trans(1 , 1, 2)Rot y (/ 6) =1 0 0 10 1 0 10 0 1 20 0 0 1

    32 0

    12 0

    0 1 0 0

    12 0

    32 0

    0 0 0 1

    =

    32 0

    12 1

    0 1 0 1

    12 0

    32 2

    0 0 0 1

    .

    Rotations about an arbitrary line in the space will be presented in the next lecture.

    6 Application 2 Orientation of a Rigid Body

    A rigid body has a coordinate frame attached to itself and located often at the center of mass. Thisframe is referred to as the body frame or local frame . The position, orientation, and motion of thebody can be described using the body frame relative to a xed reference frame, called the world frame .

    Body Frame

    World Framey

    x

    z

    xB

    z B

    yB

    Figure 4 : Body frame (local) vs. world frame (global).

    The rigid body in the space has six degrees of freedom. The position of the body can bedescribed by the x, y, z coordinates of its center of mass (i.e., the origin of the local frame) in theworld frame.

    Roll

    Pitch

    Yaw

    Figure 5 : Roll, pitch, yaw of an aircraft.

    The orientation of the body can be described bythree angles which together determine the rotationof the body frame from the world frame. Thesethree angles are called Euler angles . Each rotationis performed about an axis of the (moving) body

    frame instead of some axis of a (xed) world frame.An aircraft in ight can perform three indepen-dent rotations: roll , about an axis from nose to tail;pitch , nose up or down about an axis from wing towing; and yaw , nose left or right about an axis fromtop to bottom.

    8

  • 8/12/2019 Homogeneous Transform

    9/10

    There are several conventions for Euler angles, depending on the axes about which the rotationsare carried out. Here we introduce the Z -Y -X Euler angles. The body frame starts in the sameorientation as the world frame. To achieve its nal orientation, the rst rotation is by an angle, about the body z-axis, the second rotation by an angle [0, ] about the body y-axis, andthe third rotation by an angle about the body x-axis. Here, , , and are referred to as yaw,pitch, and roll, respectively. The three rotations are illustrated in Figure 6, where x

    B -y

    B -z

    B andx B -yB -z

    B are the two intermediate congurations of the body frame xB -yB -zB .

    y

    z, z B

    y B yB

    x B

    z B yB

    x

    B , x Bx B

    z By B , y

    B

    z Bz B

    x

    x

    B

    Figure 6 : Z -Y -X Euler angles (yaw), (pitch), (roll).

    Now we derive the homogeneous transformation matrix. Consider a point p in the body framexB -yB -zB . Let us determine its coordinates in the original frame x-y-z by considering the fourframes backward: xB -yB -zB , x B -y

    B -z

    B , x

    B -y

    B -z

    B , and x-y-z. Since the frame xB -yB -zB is obtained

    from the frame xB -yB -z

    B by a rotation about the x

    B -axis through an angle , the coordinates of

    p in the latter frame is Rot x () p. Next, the frame xB -y

    B -z

    B is obtained from the frame x

    B -

    yB -zB after a rotation about the y

    B -axis through an angle . So the same point has coordinates

    Rot y ()(Rot x () p) in the frame xB -y

    B -z

    B . Similarly, the coordinates of the point in the frame

    x-y-z is Rotz ()(Rot y ()(Rot x ()

    p)). Thus the transformation matrix associated with the Z -Y -Z

    Euler angles are

    Rot zyx (,,) = Rot z () Rot y () Rot x ()

    =

    cos sin 0 0sin cos 0 00 0 1 00 0 0 1

    cos 0 sin 00 1 0 0

    sin 0 cos 00 0 0 1

    1 0 0 00 cos sin 00 sin cos 00 0 0 1

    =

    cos cos cos sin sin sin cos cos sin cos + sin sin 0sin cos sin sin sin + cos cos sin sin cos cos sin 0sin cos sin cos cos 00 0 0 1

    .

    Given the rotation matrix, we can extract the Euler angles , , and .

    References

    [1] D. Marsh. Applied Geometry for Computer Graphics and CAD . Springer-Verlag, 1999.

    9

  • 8/12/2019 Homogeneous Transform

    10/10

    [2] J. Craig. Introduction to Robotics: Mechanics and Control . 2nd ed., Addison-Wesley, 1989.

    [3] Wolfram MathWorld. http://mathworld.wolfram.com/EulerAngles.html .

    10