2D and 3D Coordinate Systems and Transformations

Size: px
Start display at page:

Download "2D and 3D Coordinate Systems and Transformations"

Transcription

1 Graphics & Visualization Chapter 3 2D and 3D Coordinate Systems and Transformations Graphics & Visualization: Principles & Algorithms

2 Introduction In computer graphics is often necessary to change: the form of the objects the coordinate system Examples: In a model of a scene, the digitized form of a car may be used in several instances, positioned at various points & directions and in different sizes In animation, an object may be transformed from frame to frame As objects traverse the graphics pipeline, they change their coordinate system: object coordinates world coordinates world coordinates eye coordinates Coordinates transformations: - tools of change - the most important & classic topic in computer graphics 2

3 Introduction (2) Points in 3D Euclidean space E 3 : 3 1 column vectors (here) p p p p x y z Linear transformations: matrices - they are post-multiplied by a point to produce another point p m m m p p m m m p p x y z m m m p x y z 3

4 Introduction (3) If points were represented by 1 3 row vector p [ px py pz ] the linear transformations would be pre-multiplied by the point p p p p p p m m m x y z x y z m m m m m m Right-handed three-dimensional coordinate systems are used: 4

5 Affine Transformations - Combinations Mathematics: Transformations: mappings whose domain & range are the same set (e.g. E 3 to E 3 ) Computer graphics & visualization: Affine Transformations: transformations which preserve important geometric properties of the objects being transformed Affine transformations preserve affine combinations Examples of Affine combinations: line segments, convex polygons, triangles, tetrahedra the building blocks of our models 5

6 3 3 An affine combination of points p,p,...,p E is a point p E : where Affine Combinations a : affine coordinates of p with respect to, a1,..., a p n,p 1,...,pn i n a i Convex affine combination: 1 p i 1 n if all a i, i =,1,,n The affine combination p is within the convex hull of the original points p,...,p E.g.1: Line segment between points p 1 and p 2 is the set of points p: p = a 1 p 1 + a 2 p 2 with a 1 1 and a 2 = 1 a 1 E.g. 2: Triangle with vertices p 1,p 2,p 3 is the set of points p: n a i p = a 1 p 1 + a 2 p 2 + a 3 p 3 with a 1, a 2, a 3 1 and a 1 + a 2 + a 3 = 1 p i n 6

7 Affine transformation: transformation which preserves affine combinations it retains the inter-relationship of the points 3 3 A transformation : E E is affine if n where p a p : an affine combination The result of the application of an affine transformation onto the result p of an affine combination should equal the affine combination of the result of performing the affine transformation on the defining points with the same weights a i E.g. Affine Transformations i i i n ( p) a ( p ) i i i 7

8 Affine Transformations (2) Practical consequence: Internal points need not be transformed It suffices to transform the defining points E.g. to perform an affine transformation on a triangle: Transform its three vertices only, not its (infinite) interior points General affine transformation Mappings of the form ( p) A p t are affine transformations in E 3. (1) where A is a 3 3 matrix Proof: we shall show that (1) preserves affine combinations n n n n ( a p ) A( a p ) t a Ap a t i i i i i i i i i i i i n a( A p t) a ( p ). i i i n i i t is a 3 1 matrix 8

9 2D Affine Transformations 2D results generalize to 3D Four basic affine transformations: translation scaling rotation shearing 9

10 2D Translation Defines a movement by a certain distance in a certain direction, both specified by the translation vector T The translation of a 2D point p=[x,y] by a vector d [ d, ] T x dy gives another T point p'=[x',y'] : p p d Instantiation of ( ) where (I is the 2 2 identity matrix) p A p t and A I t d 1

11 2D Scaling Changes the size of objects Scaling factor: specifies the change in each direction 2D: s x & s y are the scaling factors which are multiplied by the respective coordinates of p=[x, y] T Scaling of 2D point p=[x, y] T to give p =[x, y ] T : p S( s, s ) p where S( s, s ) x y x y Instantiation of ( p) A p t where A S( s, s ) and t s x s x y y 11

12 2D Scaling (2) Not possible to observe the effect on a single point If scaling factor < 1 reduce the object s size scaling factor > 1 increase the object s size Translation side-effect (proportional to the scaling factor): The object has moved toward the origin of the x-axis (s x < 1) The object has moved away from the origin of the y-axis (s y > 1) Isotropic scaling: If all the scaling factors are equal (in 2D s x = s y ) Preserves the similarity of objects (angles) Mirroring: Special case, using a -1 scaling factor About x-axis: S(1,-1) and y-axis: S(-1,1) 12

13 2D Rotation Turns the objects about the origin The distance from the origin does not change, only the orientation changes Counterclockwise rotation is positive p [ x, y ] T p [ xy, ] T We can estimate from : x l cos( ) l(cos cos sin sin ) x cos y sin y l sin( ) l(cos sin sin cos ) x s in y cos Thus: p R( ) p 13

14 2D Rotation (2) where: R() cos sin sin cos Rotation is an instantiation of the general affine transformation ( p) A p t where A R() and t 14

15 2D Shear Increases one of the object s coordinates by an amount equal to the other coordinate times a shearing factor Physical example: cards placed flat on a table and then tilted by a hard book. 15

16 2D Shear (2) p [ x, y ] T p [ xy, ] T We can estimate from : shear along x axis x shear along y axis x x x, ay, y y bx y y where α and b are the respective shear factors In matrix form: shear on x axis shear on y axis p SH ( a) p p SH ( b) p x y, where, where SH x ( a) SH y () b 1 a 1 1 b 1 Shear is an instantiation of the general affine transformation ( p) A p t where A SH ( a) or A SH () b and t x y 16

17 Composite Transformations Useful transformations in computer graphics and visualization rarely consist of a single basic affine transformation All transformations must be applied to all objects of a scene Objects are defined by thousands or even millions of vertices EXAMPLE: Rotate a 2D object by 45 o and then isotropically scale it by a factor of 2 Apply the rotation matrix: R(45 ) Then apply the scaling matrix: S(2,2)

18 Composite Transformations (2) It is possible to apply the matrices sequentially to every vertex p: S(2, 2) (R(45 o ) p) NOT EFFICIENT Another way is to exploit the associative property of matrix multiplication and apply the pre-computed composite to the vertices: (S(2, 2) R(45 o ) )p MORE EFFICIENT Thus the composite transformation is only computed once and the composite matrix is applied to the vertices Matrix multiplication is not commutative the order of multiplying the transformation matrices is important Having chosen the column representation of points transformation matrices are right-multiplied by the points write the matrix composition in the reverse of the order of application 18

19 Composite Transformations (3) To apply the sequence of transformations T1,T2,...,Tm, we compute the composite matrix Tm... T2 T1 Problem with the translation transformation: Translation cannot be described by a linear transformation matrix such as: x ax by y cx dy Thus translation cannot be included in a composite transformation Solution to the problem homogeneous coordinates 19

20 Homogeneous Coordinates Homogeneous Coordinates use one additional dimension than the space we want to represent x 2D space: y, where w is the new coordinate that corresponds to w the extra dimension; w Fixing w=1 maintains our original dimensionality by taking slice w=1 In 2D we use the plane w=1 instead of the xy-plane 2

21 Homogeneous Coordinates (2) Points whose homogeneous coordinates are multiples of each other are equivalent: e.g., [1,2,3] T and [2,4,6] T represent the same point The actual point that they represent is given by their unique basic representation, which has w = 1 and is obtained by dividing all coordinates by w: [x/w, y/w, w/w] T = [x/w, y/w, 1] T In general, we use the basic representation for points, and we ensure that our transformations preserve this property 21

22 Homogeneous Coordinates (3) How do homogeneous coordinates treat the translation problem? Exploit the fact that points have w = 1, in order to represent the translation of a point p = [x, y, w] T by a vector d [ d, ], as a x dy linear transformation: x 1x y d w x d y x 1y d w y d w x y 1w 1 x y x y Transformation on the w-coordinate ensures that the resulting point p [ x, y, w ] T has w 1 22

23 Homogeneous Coordinates (4) The above linear expressions can be encapsulated in matrix form, thus treating translation in the same way as the other basic affine transformations In non-homogeneous transformations, the origin [, ] T is a fixed point: a c b d A positive effect of homogeneous coordinates is that there is no fixed point under homogeneous affine transformations 23

24 Homogeneous Coordinates (4) The 2D origin is now [,, 1] T which is not a fixed point The point [,, ] T is outside w=1 plane disallowed since it has w= From here on points will be represented by their homogeneous coordinates: 2D [x, y, 1] T 3D [x, y, z, 1] T 24

25 2D Homogeneous Affine Transformations 2D homogeneous translation matrix: Translation is treated like the other basic affine transformations: p T( d) p The last row of a homogeneous transformation matrix is always [,, 1] in order to preserve the unit value of the w-coordinate 2D homogeneous scaling matrix: 1 Td ( ) 1 d d 1 x y S( s, s ) s s x y y x 1 25

26 2D Homogeneous Affine Transformations (2) 2D homogeneous rotation matrix: 2D homogeneous shear matrices: cos sin R( ) sin cos 1 shear on x axis shear on y axis 1 a SH x ( a) SH y ( b) b

27 2D Homogeneous Inverse Transformations Often necessary to reverse a transformation 2D inverse homogeneous translation matrix: 1-1 T ( d) T( -d) 1 1 2D inverse homogeneous scaling matrix: -1 S 1 s d d x y ( sx, sy) S(, ) s s s x y y x 1 27

28 2D Homogeneous Inverse Transformations (2) 2D inverse homogeneous rotation matrix: -1 R 2D inverse homogeneous shear matrix: shear on x axis SH shear on y axis SH cos sin ( ) R( ) sin cos -1 x -1 y 1 1 a ( a) SH ( a) 1 x 1 1 ( b) SH ( b) b 1 y 1 28

29 2D Homogeneous Inverse Transformations Applying an object transformation on an object is equivalent to the application of the inverse transformation on the coordinate system (axis transformation) EXAMPLE: Isotropically scaling an object by a factor of 2 is equivalent to isotropically scaling the coordinate system axis by a factor of 1/2 (shrinking) 29

30 Properties of Homogeneous Matrices Some properties of homogeneous affine transformation matrices: T( d1) T( d2) T( d2) T( d1) T( d1 d2) S( s, s ) S( s, s ) S( s, s ) S( s, s ) S( s s, s s ) x1 y1 x2 y2 x2 y2 x1 y1 x1 x2 y1 y2 R( 1) R( 2) R( 2) R( 1) R( 1 2) S( s, s ) R( ) R( ) S( s, s ) for isotropic scaling only (s x =s y ) x y x y 3

31 2D Transformation Example 1 EXAMPLE 1: Rotation about an arbitrary point Determine the transformation matrix R(θ, p) required to perform rotation about an arbitrary point p by an angle θ SOLUTION Step 1: Translate by p, T( p) Step 2: Rotate by θ, R(θ) Translate by p, T( p) 1 p cos sin 1 p cos sin p p cos p sin x x x x y R(, p) 1 p sin cos 1 p sin cos p p sin p cos y y y x y

32 2D Transformation Example 2 EXAMPLE 2: Rotation of a triangle about a point Rotate the triangle a=[,]t, b=[1,1] T and c=[5,2] T SOLUTION abc by 45 o about the point p=[-1,-1] T, where The triangle can by represented by the matrix We shall apply R(θ, p) [Ex. 1] to the triangle: T R(45,[ 1, 1] ) T The rotated triangle is abcwhere a =[-1, 2 1] T, b =[-1, 2 2 1] T 3 9 and c =[ 2 1, 2 1 ] T 2 2 T 32

33 2D Transformation Example 3 EXAMPLE 3: Scaling about an arbitrary point Determine the transformation matrix S(s x,s y,p) required to perform scaling by s x and s y about an arbitrary point p SOLUTION Step 1: Translate by p, T( p) Step 2: Scale by s x and s y, S(s x,s y ) p, T( p) Step 3: Translate by to undo the initial translation 1 p s 1 p s p p s x x x x x x x S( s, s, p) 1 p s 1 p s p p s x y y y y y y y y

34 2D Transformation Example 4 EXAMPLE 4: Scaling of a triangle about a point Double the lengths of the sides of triangle keeping its vertex c fixed. The coordinates of its vertices are a=[,]t, b=[1,1] T, c=[5,2] T SOLUTION abc The triangle can by represented by the matrix T [Ex. 2] We shall apply the matrix S(s x,s y,p) [Ex. 3] to the triangle, setting the scaling factor equal to 2 and p=c T S(2,2,[5,2,1] ) T The scaled triangle is abc where a =[-5,-2] T, b =[-3,] T and c =[5,2] T 34

35 2D Transformation Example 5 EXAMPLE 5: Axis transformation Suppose that the coordinate system is translated by the vector v [ v, v ] T. Determine the matrix that describes this effect SOLUTION The required transformation matrix must produce the coordinates of the objects with respect to the new coordinate system. This is achieved by applying the inverse translation to the objects: x y 1 T( v) 1 v v 1 x y Similar argument holds for any other axis transformation. Its effect is encapsulated by applying the inverse transformation to the objects 35

36 2D Transformation Example 6 EXAMPLE 6: Mirroring about an arbitrary axis Determine the transformation matrix required to perform mirroring about an axis specified by a point p=[p x,p y ] T and a direction vector v [ v, ] T x vy SOLUTION Step 1: Translate by p, T( p) Step 2: Rotate by θ (negative as it is clockwise), R(-θ) θ forms between x-axis and vector sin v v y v 2 2 x y and: The two previous steps make the general axis coincide with the x-axis Step 3: Perform mirroring about the x-axis, S(1, -1) Step 4: Rotate by θ, R(θ) v cos v v x v 2 2 x y 36

37 2D Transformation Example 6 (2) Step 5: Translate by p, T( p) Summarizing the previous steps we have: M SYM 1 p cos sin 1 cos sin 1 x 1 p sin cos 1 sin cos 1 y cos sin 2sin cos px px(cos sin ) 2 py sin cos sin cos sin cos py py (sin cos ) 2 px sin cos 1 p p x y 37

38 2D Transformation Example 7 EXAMPLE 7: Mirror polygon Given a polygon, determine its mirror polygon with respect to (a) the line y=2 and (b) the axis specified by the point p=[,2] T and the vector The polygon is given by its vertices a=[-1,] T, b=[,-2] T, c=[1,] T and d=[,2] T SOLUTION The polygon can be represented by matrix In case (a) p=[,2] T and v [1,] T thus θ= ο, sinθ=, cosθ=1 and we have: MSYM Π Π v [1,1] T 38

39 2D Transformation Example 7 (2) v [1,1] T In case (b) p=[,2] T and thus sinθ = cosθ = 1 2 and we have: MSYM Π where M SYM is the matrix of [Ex. 6] 39

40 2D Transformation Example 8 EXAMPLE 8: Window-to-Viewport transformation The contents of a 2D window must be transferred to a 2D viewport. Both the window and viewport are rectangular parallelograms with sides parallel to the x- and y-axis. Determine the window to viewport transformation matrix. Also determine how objects are deformed by this transformation. SOLUTION Suppose that the window and the viewport are defined by two opposite T T T T vertices [ wxmin, wymin ],[ wxmax, w ymax ] and [ vxmin, vymin ],[ vxmax, vymax ] Step 1: Translate [ w, w ] T to the origin, using T( w ) where w min [ w, w ] T xmin ymin xmin ymin min 4

41 2D Transformation Example 8 (2) Step 2: Scale the window to the size of the viewport, using S(s x, s y ) where vxmax v v xmin ymax vymin sx sy w w w w Step 3: Translate to the minimum viewport vertex [ v, v ] T, using xmax xmin Tv where [ v, v ] T ( ) min v min xmin ymin Summarizing the previous steps we have: M T( v ) S( s, s ) T( w ) WV min x y min ymax ymin vxmax vxmin wxmax wxmin 1 vxmin 1 w vymax vymin 1 vymin 1 w wymax wymin xmin xmin ymin ymin 41

42 2D Transformation Example 8 (3) Finally : M WV v v v v vxmin wxmin w w w w xmax xmin xmax xmin xmax xmin xmax xmin v v v v v w w w w w ymax ymin ymax ymin ymin ymin ymax ymin ymax ymin 1 42

43 2D Transformation Example 8 (4) M WV contains non-isotropic scaling (s x s y ) objects will be deformed. A circle will become an ellipse and a square will become a rectangular parallelogram. The aspect ratios of the window and the viewport are defined as the ratios of their x- to their y-sizes: a w w w v v, av w w v v xmax xmin xmax xmin ymax ymin ymax ymin If a w a v then objects are deformed. To avoid this, is to use the largest part of the viewport with the same aspect ratio as the window. For example we can change the v xmax or the v ymax boundary of the viewport in the following manner: if (a v >a w ) then v xmax = v xmin + a w *(v ymax v ymin ) else if (a v <a w ) then ( vxmax vxmin ) vymax vymin a w 43

44 2D Transformation Example 9 EXAMPLE 9: Window-to-Viewport transformation instances Determine the window-to-viewport transformation from the window: [ w, w ] T [1,1] T,[ w, w ] T [3,5] T xmin ymin xmax ymax [ v, ] T [,] T,[, ] T [1,1] T xmin vymin vxmax vymax to the viewport : If there is deformation, how can it be corrected? SOLUTION Direct application of the M WV [Ex. 8] For the window and viewport pair gives 1 1 Now aw and av, so there is distortion since ( av aw) 2. It can 1 be corrected by reducing the size of the viewport by setting: 1 vxmax vxmin aw *( vymax vymin ) 2 44 M WV

45 2D Transformation Example 1 EXAMPLE 1: Tilted window-to-viewport transformation Suppose that the window is tilted and given by its four vertices a=[1,1] T, b=[5,3] T, c=[4,5] T and d=[,3] T. Determine the transformation TILT M WV SOLUTION that maps it to the viewport [ v, v ] [,],[ v, v ] [1,1] T T T T xmin ymin xmax ymax Step 1: Rotate the window by angle θ about a point a. For this we shall use matrix R(θ, p) [Ex. 1], instantiating it as R(-θ, a) where 1 2 sin cos 5 5 Step 2: Apply the window to viewport transformation M WV [Ex. 8] 45

46 Before Step 2 we must determine the maximum x- and y- coordinates of the rotated window by computing: Thus 2D Transformation Example 1 (2) c R(, a) c 1 5 T [ w, w ] a,[ w, w ] xmin ymin xmax ymax T 1 c, and we have: TILT MWV MWV R(, a)

47 3D Homogeneous Affine Transformations 3D homogeneous coordinates are similar to 2D Add an extra coordinate to create [x, y, z, w] T where w corresponds to the extra dimension Points whose homogeneous coordinates are multiples are equivalent e.g. [1, 2, 3, 2] T and [2, 4, 6, 4] T Basic representation of a point is unique has w=1 is obtained by dividing by w : [x/w, y/w, z/w, w/w] T = [x/w, y/w, z/w, 1] T, w Example: T T [,,, ] T [,,, ] [,1,,1] Obtain a 3D projection of 4D space by setting w=1 Points: 4 1 vectors. Transformations: 4 4 matrices 47

48 3D Homogeneous Translation Specified by a 3-dimensional vector Matrix form: 1 1 Td ( ) 1 d d d 1 x y z d [ d, d, d ] x y z T Td ( ) can be combined with other affine transformation matrices by matrix multiplication Inverse translation: T 1 ( d) T( d) 48

49 3D Homogeneous Scaling Three scaling factors: s x, s y, s z If scaling factor < 1 the object s size is reduced in the respective dimension scaling factor > 1 the object s size is increased Matrix form: S( s, s, s ) x y z s x s y s 1 z Scaling has a translation side-effect, proportional to the scaling factor 49

50 3D Homogeneous Scaling (2) Isotropic scaling: if s x = s y = s z preserves the similarity of objects (angles) Mirroring: about one of the major planes (xy, xz, yz) using a -1 scaling factor e.g. mirroring about the xy-plane is S(1, 1, -1) Inverse scaling: S ( sx, sy, sz ) S(,, ) s s s x y z 5

51 3D Homogeneous Rotation Different from 2D rotation: rotate about an axis, not a point Basic rotation transformations: rotate about the 3 main axes x, y, z Rotation about an arbitrary axis: by combining basic rotations Positive rotation about an axis α: in right-handed coordinate system is the one in the counterclockwise direction when looking from the positive part of an axis toward the origin Positive rotation about y-axis 51

52 3D Homogeneous Rotation(2) The distance from the axis of rotation does not change Rotation does not affect the coordinate that corresponds to the axis of rotation Rotation matrices about the main axes: R x ( ) 1 cos sin sin cos 1 R y ( ) cos sin 1 sin cos 1 R z ( ) cos sin sin cos 1 1 Inverse rotation: R ( ) R ( ), R ( ) R ( ) and R ( ) R ( ), x x y y z z Rotations can also be expressed using quaternions 52

53 3D Homogeneous Shear Shears object along one of the major planes Increases 2 coordinates by an amount equal to the 3 rd coordinate times the respective shearing factors 3 cases in 3D shear: xy, xz, yz xy shear: increases x by increases y by SH xy ( ab, ) 1 a 1 b 1 1 SH xz a z coordinate b z coordinate ( ab, ) 1 a 1 b 1 1 SH yz Similar for xz & yz : ( ab, ) 1 a b Inverse shear: SH SH SH -1 xy -1 xz -1 yz ( a, b) SH ( a, b), xy ( a, b) SH ( a, b), xz ( a, b) SH ( a, b) yz 53

54 EXAMPLE 11: Composite Rotation - Bending Compute the bending matrix: rotation about the x-axis by θ x rotation about the y-axis by θ y Does the order of the rotations matter? SOLUTION 1. 3D Transformation Example Compute the reverse order cos sin 1 cos sin sin cos sin y y y x y x y 1 cos x sin x cos x sin x MBEND Ry ( y) Rx( x) sin cos sin cos sin sin cos cos cos y y x x y x y x y cos sin cos sin y y y y cos x sin x 1 sin x sin y cos x sin x cos y MBEND Rx( x) Ry ( y) sin cos sin cos cos sin sin cos cos x x y y x y x x y M BEND M' BEND so the order of the rotations matters 54

55 3D Transformation Example 12 EXAMPLE 12: Alignment of Vector with Axis Determine the transformation v [ abc,, ] T SOLUTION with the unit vector Av ( ) that aligns a given vector ˆk along the positive z-axis. Using two rotations: v Initial Step1 Step 2 Step 1: Rotate about x by θ 1 so that v is mapped onto v 1 which lies on the xz-plane, R x (θ 1 ) Step 2: Rotate about y by θ 2 so that it coincides with ˆk, R y (θ 2 ) v 1 55

56 3D Transformation Example 12 (2) Alignment matrix ( ) : Compute angle θ 1 : Av A v Ry 2 Rx 1 ( ) ( ) ( ) θ 1 is equal to the angle formed between the projection of v onto the yz-plane and the z-axis For the tip p of v we have p=[a, b, c] T The tip of its projection on yz is p =[, b, c] T Assuming that b, c are not both we get: sin b c, cos b c b c Thus, R x ( ) 1 1 cos sin 1 1 sin cos c b b c b c b c b c b c 1 56

57 Apply R x (θ 1 ) to v, to get its xz projection : Note that: Compute θ 2 : sin Thus 3D Transformation Example 12 (3) R y a a b v R ( ) v R ( ) c b c x 1 x v v a b c a 2 2, cos b c a b c a b c ( ) v b c a cos 2 sin 2 a b c a b c 1 1 sin cos a b c a b c a b c 1 57

58 3D Transformation Example 12 (4) Compute matrix Av ( ): A( v) R ( ) R ( ) y 2 x 1 ab ac v v v c b a b c v v v 1 where v a b c and b c Compute the inverse matrix Av ( ) 1 (useful in next example): 1 A ( v) ( R ( ) R ( )) R ( ) R ( ) R ( ) R ( ) y 2 x 1 x 1 y 2 x 1 y 2 If b=c= then v coincides with the x-axis rotate about y by 9 or -9 depending on the sign of α A v R y 2 ( ) ( ) a v v a a 1 a a 1 ab c b v v ac b c v v 1 58

59 3D Transformation Example 13 EXAMPLE 13: Rotation about an Arbitrary Axis using 2 Translations & 5 Rotations Find the transformation which performs a rotation by an angle θ about an arbitrary axis specified by a vector v and a point p. SOLUTION Av ( ) transformation [Ex. 12] : aligns an arbitrary vector with z-axis use it to reduce the problem to rotation around z Step 1: Translate p to the origin, T( p) Step 2: Align v with the z-axis using Av ( ) matrix Step 3: Rotate about the z-axis by the desired angle θ, R z () -1 Step 4: Undo the alignment, A ( v) Step 5: Undo the translation, Tp ( ) -1 M T( p) A ( v) R ( ) A( v) T( p) ROT-AXIS z 59

60 3D Transformation Example 14 EXAMPLE 14: Coordinate System Transformation using 1 Translation&3 Rotations Determine the transformation M ALIGN required to align a given 3D coordinate system with basis vectors ( ˆl, mˆ, nˆ) with the xyz coordinate system with basis vectors ( ˆˆ i, j, kˆ ). The origin of the 1 st coordinate system relative to xyz is O lmn. SOLUTION Axis transformation: aligning the ( ˆl, mˆ, nˆ) basis to ( ˆˆ i, j, kˆ ) the basis changing an object s system from ( ˆˆ i, j, kˆ ) to The solution is an extension of Av ( )[Ex. 12] ( ˆl, mˆ, nˆ) 6

61 3D Transformation Example 14 (2) Step 1: Translate by -O lmn to make the 2 origins coincide, Step 2: Align the ˆn basis vector with the ˆk basis vector, using of [Ex. 12], An ( ˆ) T( O lmn ) Av ( ) Step 3: Rotate by φ around the z-axis to align the other 2 axes, R z ( ) M ˆ ALIGN Rz( ) A( n) T( Olmn) Necessary to transform the ˆl or the ˆm vector by An ( ˆ) to estimate φ. e.g. m A( nˆ) mˆ : the sinφ and cosφ values required for the rotation are then the x and y components of m 61

62 3D Transformation Example 14 (3) CONCRETE EXAMPLE : The orthonormal basis vectors of the 2 coordinate systems are: and the origins of the 2 coordinate systems coincide ( O lmn = [..] T ). Find the transformation. 1 ˆi, ˆj 1, kˆ ˆ l, mˆ, nˆ M ALIGN The basis vectors of the 2 nd system are expressed in terms of the 1 st From the coordinates of ˆn [Ex. 12]: a, b, c and λ b c ( ) ( ) ;

63 3D Transformation Example 14 (4) Compute An ( ˆ) : Compute m : An ( ˆ) mˆ A( nˆ ) mˆ A( nˆ ) So sin and cos

64 3D Transformation Example 14 (5) Compute ( ) : R z R z ( ) Compute T( O lmn ) : the origins of the 2 coordinate systems coincide so So, T( O ) ID lmn M R ( ) A( nˆ ) T( O ) ALIGN z lmn M ( ) ( ˆ ALIGN Rz A n) ID %

65 3D Transformation Example 15 EXAMPLE 15: Change of Basis Determine the transformation M BASIS required to change the orthonormal basis of a coordinate system with from B1 ( ˆi ˆ ˆ 1, j 1, k 1 ) to B2 ( ˆi ˆ ˆ 2, j 2, k 2 ) and vice versa. SOLUTION Let the coordinates of the same vector in the 2 bases be vb 1 and vb2. If the coordinates of the ˆi, ˆj,kˆ basis vectors in B1 are: a d p ˆi b ˆj e kˆ q 2, B1 2, B1 2, B1 c f r then (from linear algebra): v a d p b e q v B1 B2 c f r 65

66 3D Transformation Example 15 (2) Thus, 1 M BASIS a d p b e q c f r B2 is an orthonormal basis M 1 BASIS is an orthonormal matrix a b c M BASIS 1 ( M ) BASIS Τ d e f p q r Homogeneous form: M BASIS a b c d e f p q r 1 66

67 3D Transformation Example 16 EXAMPLE 16: Coordinate System Transformation using Change of Basis Use the change-of-basis result of Ex. 15 to align a given 3D coordinate system with basis vectors ( ˆl, mˆ, nˆ) with the xyz-coordinate system with basis vectors ( ˆˆ i, j, kˆ ). The origin of the 1 st coordinate system relative to xyz is O lmn. SOLUTION This is an axis transformation: ( ˆˆ i, j, kˆ ) changing an object s coordinate system from to ( ˆl, mˆ, nˆ) Change-of-basis replaces the 3 rotational transformations in Ex. 14 Step 1: Translate by O lmn to make the 2 origins coincide, Step 2: Use to change the basis from ( ˆˆ i, j, kˆ ) to ( ˆl, mˆ, nˆ) M BASIS T( O ) lmn 67

68 3D Transformation Example 16 (2) M M T( O ) ALIGN2 BASIS lmn a b c ( a o b o c o ) d e f ( d o e o f o ) p q r ( p o q o r o ) 1 x y z x y z x y z Where the basis vectors (l,m,n) ˆ ˆ ˆ expressed in the basis (i, ˆˆj,k) ˆ are: ˆl [ a, b, c] T, mˆ [ d, e, f ] T, nˆ [ p, q, r] T and O lmn [ ox, oy, oz] CONCRETE EXAMPLE [of Ex 14]: No translation because the 2 origins coincide. M BASIS with homogeneous form M BASIS

69 EXAMPLE 17: Rotation about an Arbitrary Axis using Change of Basis Use the change-of-basis result of Ex. 15 to find an alternative transformation which performs a rotation by an angle θ about an arbitrary axis specified by a vector v and a point p. SOLUTION Let 3D Transformation Example 17 a v b and p c Equation of plane perpendicular to v through p: α(x-x p )+b(y-y p )+c(z-z p )= Let: q a point on that plane, such that q p and m q p and l m v Normalize the vectors l,m, v to define a coordinate system basis (l,m,n) ˆ ˆ ˆ with one axis being v and the other 2 axes on the given plane M BASIS Use transformation to align it with the xyz-coordinate system Perform the desired rotation by θ around the z-axis x y z p p p 69

70 3D Transformation Example 17 (2) Step 1: Translate p to the origin, T( p) Step 2: Align the (l,m, ˆ ˆ v) ˆ basis with the (i, ˆˆj,k) ˆ basis, Step 3: Rotate about the z-axis by desired angle θ, R z () Step 4: Undo alignment, -1 M BASIS Step 5: Undo the translation, Tp ( ) M BASIS 1 M T( p) M R ( ) M T( p) ROT AXIS2 BASIS z BASIS The algebraic derivation of the MROT AXIS2 matrix is simpler than M ROT AXIS 7

71 3D Transformation Example 18 EXAMPLE 18: Rotation of a Pyramid T T T Rotate the pyramid defined by the vertices a [,,], b [1,,], c [,1, ] d [,,1] T 45 T SOLUTION The pyramid is represented by a matrix P : and by about the axis defined by c and the vector v [,1,1]. P a b c d

72 3D Transformation Example 18 (2) Rotate the pyramid : use the matrix. -1 M T( p) A ( v) R ( ) A( v) T( p) The submatrices: M ROT-AXIS ROT-AXIS z T( c) A( v) Rz (45 ) A ( v) Tc ()

73 3D Transformation Example 18 (3) Combine the submatrices to get: M ROT AXIS Compute the rotated pyramid: The vertices of the rotated pyramid are: P MROT AXIS P a [,, ], b [,, ], c [,1,] and d [1,, ] T T T T 73

74 Quaternions Used as an alternative way to express rotation Useful for animating rotations A quaternion consists of 4 real numbers: q = (s, x, y, z) s scalar part of quaternion q v ( x, y, z) vector part of quaternion q Thus an alternative representation of quaternion q is: Can be viewed as an extension of complex numbers in 4D: Using imaginary units i, j and k such that: i 2 =j 2 =k 2 =-1 & ij=k, ji=-k and so on by cyclic permutation, quaternion q may be written as: q = s+ xi+ yj+ zk A real number u corresponds to the quaternion: q = v An ordinary vector corresponds to the quaternion: q = (, ) A point p corresponds to the quaternion: q = (, p) q ( u, ) ( s, v) v 74

75 Quaternions (2) Addition between quaternions: q q ( s, v ) ( s, v ) ( s s, v v ) Multiplication between quaternions: q q ( s s v v, s v s v v v ) ( s s x x y y z z, s x x s y z z y, s1 y2 y1s2 z1x2 x1z 2, s1z 2 z1s2 x1 y2 y1x2 ) Multiplication is associative Multiplication is not commutative The conjugate quaternion of q is defined as: It holds that: q q q q The norm of q is defined as: q q q q q s v s x y z q ( s, v) 75

76 Quaternions (3) It holds that: q1 q2 q1 q2 A unit quaternion is one whose norm: q 1 The inverse quaternion of q is defined as: q 1 1 q 2 q It holds that: q q q q q 1 If then q 1 q 76

77 Expressing rotation using quaternions Consider a rotation by an angle θ about an axis through the origin whose direction is specified by a unit vector ˆn. The rotation can be expressed by the unit quaternion: The above unit quaternion can be applied to a point p represented by 1 the quaternion p = (, p) as: Thus: where q (cos,sin nˆ ) 2 2 p q p q q p q 2 p,( s v v ) p 2 v( v p ) 2 s( v p). ( ) s cos and v sin nˆ 2 2 Notice that quaternion p represents a point p since its scalar part is Point p is exactly the image of the original point p after rotation by angle θ about the given axis 77

78 Expressing rotation using quaternions (2) Expressing 2 consecutive rotations: q ( q p q ) q ( q q ) p ( q q ) ( q q ) p ( q q ) The composite rotation is represented by the unit quaternion: q = q 2 q 1 Quaternion multiplication is simpler, requires fewer operations and is numerically more stable than rotation matrix multiplication Proof of quaternion rotation: Consider a unit vector ˆv, a rotation axis ˆn and the images ˆv, ˆv 2 of ˆv 1 after 2 consecutive rotations by θ/2 around ˆn The respective quaternions are: p (, vˆ ), p (, vˆ ), p (, vˆ ) We observe : Thus we write: q Similarly: q cos vˆ vˆ and sin nˆ vˆ vˆ 2 2 ( vˆ vˆ, vˆ vˆ ) p p p p

79 Expressing rotation using quaternions (3) Then: q p q ( p p ) p ( p p ) ( p p ) p p p p p p p since p p ( 1,) 1 because 1 1 and also p vˆ ( 1) (, ) (, vˆ ) p v Thus q p q results in the rotation of ˆv by angle θ about ˆn Using similar arguments, q p1 q results in the same rotation for ˆv 1, whereas q (, nˆ ) q yields ˆn, which agrees with the fact that ˆn is the axis of rotation 79

80 Expressing rotation using quaternions (4) Generalizing the above for an arbitrary vector: ˆv, ˆv, ˆn are linearly independent. Therefore a vector may be 1 p written as a linear combination p vˆ ˆ ˆ 1v 1 n Then: q (, p) q q (, vˆ vˆ nˆ ) q 1 1 q (, vˆ ) q q (, vˆ ) q q (, nˆ ) q 1 1 ( q (, vˆ ) q) ( q (, vˆ ) q) ( q (, nˆ ) q) 1 1 which is exactly a quaternion with scalar part and a vector part made up of the rotated components of p 8

81 Conversion between Quaternions and Rotation Matrices The rotation matrix corresponding to a rotation represented by a unit quaternion q = (s, x, y, z) is : R q If the following matrix m m m R y 2z 2xy 2sz 2xz 2sy 2 2 2xy 2sz 1 2x 2z 2yz 2sx 2 2 2xz 2sy 2yz 2sx 1 2x 2y m m m m m m represents a rotation then the corresponding quaternion q = (s, x, y, z) may be computed as follows 1 81

82 Conversion between Quaternions and Rotation Matrices (2) Step 1: 1 s m m11 m Step 2: m21 m12 m m m m x, y, z 4s 4s 4s If s = (or is a number near ), use a different set of relations: then 1 m m x m m11 m22 y 2 4x m2 m2 m21 m12 z, s 4x 4x 1 1 1,, 82

83 An Example EXAMPLE 19: Rotation of a pyramid Re- work example 18, using quaternions. SOLUTION Step 1: Translation by c, T( c) so that the axis passes through the origin Step 2: perform the rotation using R q. The quaternion that expresses the rotation by 45 o about an axis with direction ˆv is: sin 22.5 sin 22.5 q ( cos,sin vˆ ) (cos 22.5,,, ) where 1 cos cos cos 22.5,sin

84 An Example (2) Therefore: R q Step 3: Translate by c, T( c) The final transformation is: M 3 T() c R T( c) M ROT AXIS q ROT AXIS [Ex. 18] 84

85 Geometric Properties Affine transformations preserve important geometric features of objects. That s why they are used in Computer Graphics and Visualization For example let Φ be an affine transformation and p, q points, then: ( p (1 ) q) ( p) (1 ) ( q ), [,1] states that the affine transformation of a line segment under Φ is another line segment Ratios of distances on the line segment ( λ / (1-λ) ) are preserved Affine transformation subclasses: linear, similitudes, rigid 85

86 Geometric Properties (2) Linear transformation can be presented by a matrix A Linear: all homogeneous affine transformations Similitudes preserve the similarity of objects. The result is identical to the initial object, except for its size Similitudes: rotation, translation, isotropic scaling Rigid transformations preserve all the geometric features of objects Rigid: rotations and translations 86

Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections

Overview. Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections Overview Affine Transformations (2D and 3D) Coordinate System Transformations Vectors Rays and Intersections ITCS 4120/5120 1 Mathematical Fundamentals Geometric Transformations A set of tools that aid

More information

2D TRANSFORMATIONS AND MATRICES

2D TRANSFORMATIONS AND MATRICES 2D TRANSFORMATIONS AND MATRICES Representation of Points: 2 x 1 matrix: x y General Problem: B = T A T represents a generic operator to be applied to the points in A. T is the geometric transformation

More information

UNIT 2 2D TRANSFORMATIONS

UNIT 2 2D TRANSFORMATIONS UNIT 2 2D TRANSFORMATIONS Introduction With the procedures for displaying output primitives and their attributes, we can create variety of pictures and graphs. In many applications, there is also a need

More information

Graphics and Interaction Transformation geometry and homogeneous coordinates

Graphics and Interaction Transformation geometry and homogeneous coordinates 433-324 Graphics and Interaction Transformation geometry and homogeneous coordinates Department of Computer Science and Software Engineering The Lecture outline Introduction Vectors and matrices Translation

More information

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates Department of Computer Science and Software Engineering The Lecture outline Introduction Vectors and matrices Translation

More information

Transformations: 2D Transforms

Transformations: 2D Transforms 1. Translation Transformations: 2D Transforms Relocation of point WRT frame Given P = (x, y), translation T (dx, dy) Then P (x, y ) = T (dx, dy) P, where x = x + dx, y = y + dy Using matrix representation

More information

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL

Computer Graphics. Chapter 5 Geometric Transformations. Somsak Walairacht, Computer Engineering, KMITL Chapter 5 Geometric Transformations Somsak Walairacht, Computer Engineering, KMITL 1 Outline Basic Two-Dimensional Geometric Transformations Matrix Representations and Homogeneous Coordinates Inverse Transformations

More information

Section III: TRANSFORMATIONS

Section III: TRANSFORMATIONS Section III: TRANSFORMATIONS in 2-D 2D TRANSFORMATIONS AND MATRICES Representation of Points: 2 x 1 matrix: X Y General Problem: [B] = [T] [A] [T] represents a generic operator to be applied to the points

More information

Computer Graphics Geometric Transformations

Computer Graphics Geometric Transformations Computer Graphics 2016 6. Geometric Transformations Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2016-10-31 Contents Transformations Homogeneous Co-ordinates Matrix Representations of Transformations

More information

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations

3D Mathematics. Co-ordinate systems, 3D primitives and affine transformations 3D Mathematics Co-ordinate systems, 3D primitives and affine transformations Coordinate Systems 2 3 Primitive Types and Topologies Primitives Primitive Types and Topologies 4 A primitive is the most basic

More information

Last week. Machiraju/Zhang/Möller/Fuhrmann

Last week. Machiraju/Zhang/Möller/Fuhrmann Last week Machiraju/Zhang/Möller/Fuhrmann 1 Geometry basics Scalar, point, and vector Vector space and affine space Basic point and vector operations Sided-ness test Lines, planes, and triangles Linear

More information

2D and 3D Transformations AUI Course Denbigh Starkey

2D and 3D Transformations AUI Course Denbigh Starkey 2D and 3D Transformations AUI Course Denbigh Starkey. Introduction 2 2. 2D transformations using Cartesian coordinates 3 2. Translation 3 2.2 Rotation 4 2.3 Scaling 6 3. Introduction to homogeneous coordinates

More information

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Transformations. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Transformations Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico Angel: Interactive Computer Graphics 4E Addison-Wesley 25 1 Objectives

More information

CSE328 Fundamentals of Computer Graphics

CSE328 Fundamentals of Computer Graphics CSE328 Fundamentals of Computer Graphics Hong Qin State University of New York at Stony Brook (Stony Brook University) Stony Brook, New York 794--44 Tel: (63)632-845; Fax: (63)632-8334 qin@cs.sunysb.edu

More information

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University

2D Image Transforms Computer Vision (Kris Kitani) Carnegie Mellon University 2D Image Transforms 16-385 Computer Vision (Kris Kitani) Carnegie Mellon University Extract features from an image what do we do next? Feature matching (object recognition, 3D reconstruction, augmented

More information

Transformation Algebra

Transformation Algebra Transformation Algebra R. J. Renka Department of Computer Science & Engineering University of North Texas 0/07/205 Linear Transformations A point with Cartesian coordinates (x, y, z) is taken to be a column

More information

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE528 Computer Graphics: Theory, Algorithms, and Applications CSE528 Computer Graphics: Theory, Algorithms, and Applications Hong Qin Stony Brook University (SUNY at Stony Brook) Stony Brook, New York 11794-2424 Tel: (631)632-845; Fax: (631)632-8334 qin@cs.stonybrook.edu

More information

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1

1 Transformations. Chapter 1. Transformations. Department of Computer Science and Engineering 1-1 Transformations 1-1 Transformations are used within the entire viewing pipeline: Projection from world to view coordinate system View modifications: Panning Zooming Rotation 1-2 Transformations can also

More information

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects

Object Representation Affine Transforms. Polygonal Representation. Polygonal Representation. Polygonal Representation of Objects Object Representation Affine Transforms Polygonal Representation of Objects Although perceivable the simplest form of representation they can also be the most problematic. To represent an object polygonally,

More information

Chapter 2 - Basic Mathematics for 3D Computer Graphics

Chapter 2 - Basic Mathematics for 3D Computer Graphics Chapter 2 - Basic Mathematics for 3D Computer Graphics Three-Dimensional Geometric Transformations Affine Transformations and Homogeneous Coordinates Combining Transformations Translation t + t Add a vector

More information

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms

Computer Graphics with OpenGL ES (J. Han) Chapter IV Spaces and Transforms Chapter IV Spaces and Transforms Scaling 2D scaling with the scaling factors, s x and s y, which are independent. Examples When a polygon is scaled, all of its vertices are processed by the same scaling

More information

CS 4204 Computer Graphics

CS 4204 Computer Graphics CS 4204 Computer Graphics 3D Viewing and Projection Yong Cao Virginia Tech Objective We will develop methods to camera through scenes. We will develop mathematical tools to handle perspective projection.

More information

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing

Interactive Computer Graphics. Hearn & Baker, chapter D transforms Hearn & Baker, chapter 5. Aliasing and Anti-Aliasing Interactive Computer Graphics Aliasing and Anti-Aliasing Hearn & Baker, chapter 4-7 D transforms Hearn & Baker, chapter 5 Aliasing and Anti-Aliasing Problem: jaggies Also known as aliasing. It results

More information

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7

MODULE - 7. Subject: Computer Science. Module: Other 2D Transformations. Module No: CS/CGV/7 MODULE - 7 e-pg Pathshala Subject: Computer Science Paper: Computer Graphics and Visualization Module: Other 2D Transformations Module No: CS/CGV/7 Quadrant e-text Objectives: To get introduced to the

More information

Game Engineering CS S-05 Linear Transforms

Game Engineering CS S-05 Linear Transforms Game Engineering CS420-2016S-05 Linear Transforms David Galles Department of Computer Science University of San Francisco 05-0: Matrices as Transforms Recall that Matrices are transforms Transform vectors

More information

Transforms. COMP 575/770 Spring 2013

Transforms. COMP 575/770 Spring 2013 Transforms COMP 575/770 Spring 2013 Transforming Geometry Given any set of points S Could be a 2D shape, a 3D object A transform is a function T that modifies all points in S: T S S T v v S Different transforms

More information

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems

EECE 478. Learning Objectives. Learning Objectives. Linear Algebra and 3D Geometry. Linear algebra in 3D. Coordinate systems EECE 478 Linear Algebra and 3D Geometry Learning Objectives Linear algebra in 3D Define scalars, points, vectors, lines, planes Manipulate to test geometric properties Coordinate systems Use homogeneous

More information

GEOMETRIC TRANSFORMATIONS AND VIEWING

GEOMETRIC TRANSFORMATIONS AND VIEWING GEOMETRIC TRANSFORMATIONS AND VIEWING 2D and 3D 1/44 2D TRANSFORMATIONS HOMOGENIZED Transformation Scaling Rotation Translation Matrix s x s y cosθ sinθ sinθ cosθ 1 dx 1 dy These 3 transformations are

More information

2D transformations: An introduction to the maths behind computer graphics

2D transformations: An introduction to the maths behind computer graphics 2D transformations: An introduction to the maths behind computer graphics Lecturer: Dr Dan Cornford d.cornford@aston.ac.uk http://wiki.aston.ac.uk/dancornford CS2150, Computer Graphics, Aston University,

More information

Animation Curves and Splines 2

Animation Curves and Splines 2 Animation Curves and Splines 2 Animation Homework Set up Thursday a simple avatar E.g. cube/sphere (or square/circle if 2D) Specify some key frames (positions/orientations) Associate Animation a time with

More information

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01 UNIT 2 Translation/ Scaling/ Rotation Unit-02/Lecture-01 Translation- (RGPV-2009,10,11,13,14) Translation is to move, or parallel shift, a figure. We use a simple point as a starting point. This is a simple

More information

Game Engineering: 2D

Game Engineering: 2D Game Engineering: 2D CS420-2010F-07 Objects in 2D David Galles Department of Computer Science University of San Francisco 07-0: Representing Polygons We want to represent a simple polygon Triangle, rectangle,

More information

1 Affine and Projective Coordinate Notation

1 Affine and Projective Coordinate Notation CS348a: Computer Graphics Handout #9 Geometric Modeling Original Handout #9 Stanford University Tuesday, 3 November 992 Original Lecture #2: 6 October 992 Topics: Coordinates and Transformations Scribe:

More information

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations

Figure 1. Lecture 1: Three Dimensional graphics: Projections and Transformations Lecture 1: Three Dimensional graphics: Projections and Transformations Device Independence We will start with a brief discussion of two dimensional drawing primitives. At the lowest level of an operating

More information

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College

DRAFT: Mathematical Background for Three-Dimensional Computer Graphics. Jonathan R. Senning Gordon College DRAFT: Mathematical Background for Three-Dimensional Computer Graphics Jonathan R. Senning Gordon College September 2006 ii Contents Introduction 2 Affine Geometry 3 2. Affine Space...................................

More information

Transformations Week 9, Lecture 18

Transformations Week 9, Lecture 18 CS 536 Computer Graphics Transformations Week 9, Lecture 18 2D Transformations David Breen, William Regli and Maxim Peysakhov Department of Computer Science Drexel University 1 3 2D Affine Transformations

More information

Homogeneous Coordinates and Transformations of the Plane

Homogeneous Coordinates and Transformations of the Plane 2 Homogeneous Coordinates and Transformations of the Plane 2. Introduction In Chapter planar objects were manipulated by applying one or more transformations. Section.7 identified the problem that the

More information

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices

Today. Today. Introduction. Matrices. Matrices. Computergrafik. Transformations & matrices Introduction Matrices Computergrafik Matthias Zwicker Universität Bern Herbst 2008 Today Transformations & matrices Introduction Matrices Homogeneous Affine transformations Concatenating transformations Change of Common coordinate

More information

Specifying Complex Scenes

Specifying Complex Scenes Transformations Specifying Complex Scenes (x,y,z) (r x,r y,r z ) 2 (,,) Specifying Complex Scenes Absolute position is not very natural Need a way to describe relative relationship: The lego is on top

More information

Visual Recognition: Image Formation

Visual Recognition: Image Formation Visual Recognition: Image Formation Raquel Urtasun TTI Chicago Jan 5, 2012 Raquel Urtasun (TTI-C) Visual Recognition Jan 5, 2012 1 / 61 Today s lecture... Fundamentals of image formation You should know

More information

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University

Computer Graphics. P04 Transformations. Aleksandra Pizurica Ghent University Computer Graphics P4 Transformations Aleksandra Pizurica Ghent Universit Telecommunications and Information Processing Image Processing and Interpretation Group Transformations in computer graphics Goal:

More information

CT5510: Computer Graphics. Transformation BOCHANG MOON

CT5510: Computer Graphics. Transformation BOCHANG MOON CT5510: Computer Graphics Transformation BOCHANG MOON 2D Translation Transformations such as rotation and scale can be represented using a matrix M.., How about translation? No way to express this using

More information

Vector Algebra Transformations. Lecture 4

Vector Algebra Transformations. Lecture 4 Vector Algebra Transformations Lecture 4 Cornell CS4620 Fall 2008 Lecture 4 2008 Steve Marschner 1 Geometry A part of mathematics concerned with questions of size, shape, and relative positions of figures

More information

Monday, 12 November 12. Matrices

Monday, 12 November 12. Matrices Matrices Matrices Matrices are convenient way of storing multiple quantities or functions They are stored in a table like structure where each element will contain a numeric value that can be the result

More information

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review.

MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review. MATRIX REVIEW PROBLEMS: Our matrix test will be on Friday May 23rd. Here are some problems to help you review. 1. The intersection of two non-parallel planes is a line. Find the equation of the line. Give

More information

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation

Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation Geometric transformations assign a point to a point, so it is a point valued function of points. Geometric transformation may destroy the equation and the type of an object. Even simple scaling turns a

More information

Computer Vision cmput 428/615

Computer Vision cmput 428/615 Computer Vision cmput 428/615 Basic 2D and 3D geometry and Camera models Martin Jagersand The equation of projection Intuitively: How do we develop a consistent mathematical framework for projection calculations?

More information

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6 Polar Coordinates Any point in the plane can be described by the Cartesian coordinates (x, y), where x and y are measured along the corresponding axes. However, this is not the only way to represent points

More information

Coordinate Transformations & Homogeneous Coordinates

Coordinate Transformations & Homogeneous Coordinates CS-C31 (Introduction to) Computer Graphics Jaakko Lehtinen Coordinate Transformations & Homogeneous Coordinates Lots of slides from Frédo Durand CS-C31 Fall 216 Lehtinen Outline Intro to Transformations

More information

+ i a y )( cosφ + isinφ) ( ) + i( a x. cosφ a y. = a x

+ i a y )( cosφ + isinφ) ( ) + i( a x. cosφ a y. = a x Rotation Matrices and Rotated Coordinate Systems Robert Bernecky April, 2018 Rotated Coordinate Systems is a confusing topic, and there is no one standard or approach 1. The following provides a simplified

More information

2D Object Definition (1/3)

2D Object Definition (1/3) 2D Object Definition (1/3) Lines and Polylines Lines drawn between ordered points to create more complex forms called polylines Same first and last point make closed polyline or polygon Can intersect itself

More information

Coordinate transformations. 5554: Packet 8 1

Coordinate transformations. 5554: Packet 8 1 Coordinate transformations 5554: Packet 8 1 Overview Rigid transformations are the simplest Translation, rotation Preserve sizes and angles Affine transformation is the most general linear case Homogeneous

More information

with slopes m 1 and m 2 ), if and only if its coordinates satisfy the equation y y 0 = 0 and Ax + By + C 2

with slopes m 1 and m 2 ), if and only if its coordinates satisfy the equation y y 0 = 0 and Ax + By + C 2 CHAPTER 10 Straight lines Learning Objectives (i) Slope (m) of a non-vertical line passing through the points (x 1 ) is given by (ii) If a line makes an angle α with the positive direction of x-axis, then

More information

(Refer Slide Time: 00:04:20)

(Refer Slide Time: 00:04:20) Computer Graphics Prof. Sukhendu Das Dept. of Computer Science and Engineering Indian Institute of Technology, Madras Lecture 8 Three Dimensional Graphics Welcome back all of you to the lectures in Computer

More information

Three-Dimensional Viewing Hearn & Baker Chapter 7

Three-Dimensional Viewing Hearn & Baker Chapter 7 Three-Dimensional Viewing Hearn & Baker Chapter 7 Overview 3D viewing involves some tasks that are not present in 2D viewing: Projection, Visibility checks, Lighting effects, etc. Overview First, set up

More information

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES

CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES CALCULATING TRANSFORMATIONS OF KINEMATIC CHAINS USING HOMOGENEOUS COORDINATES YINGYING REN Abstract. In this paper, the applications of homogeneous coordinates are discussed to obtain an efficient model

More information

Perspective Mappings. Contents

Perspective Mappings. Contents Perspective Mappings David Eberly, Geometric Tools, Redmond WA 98052 https://www.geometrictools.com/ This work is licensed under the Creative Commons Attribution 4.0 International License. To view a copy

More information

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5)

521493S Computer Graphics Exercise 2 Solution (Chapters 4-5) 5493S Computer Graphics Exercise Solution (Chapters 4-5). Given two nonparallel, three-dimensional vectors u and v, how can we form an orthogonal coordinate system in which u is one of the basis vectors?

More information

Overview. By end of the week:

Overview. By end of the week: Overview By end of the week: - Know the basics of git - Make sure we can all compile and run a C++/ OpenGL program - Understand the OpenGL rendering pipeline - Understand how matrices are used for geometric

More information

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009

Lecture 6 Sections 4.3, 4.6, 4.7. Wed, Sep 9, 2009 Lecture 6 Sections 4.3, 4.6, 4.7 Hampden-Sydney College Wed, Sep 9, 2009 Outline 1 2 3 4 re are three mutually orthogonal axes: the x-axis, the y-axis, and the z-axis. In the standard viewing position,

More information

Chapter 5. Transforming Shapes

Chapter 5. Transforming Shapes Chapter 5 Transforming Shapes It is difficult to walk through daily life without being able to see geometric transformations in your surroundings. Notice how the leaves of plants, for example, are almost

More information

Chapter 5. Projections and Rendering

Chapter 5. Projections and Rendering Chapter 5 Projections and Rendering Topics: Perspective Projections The rendering pipeline In order to view manipulate and view a graphics object we must find ways of storing it a computer-compatible way.

More information

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics I. Guoying Zhao 1 / 52 Computer Graphics Three-Dimensional Graphics I Guoying Zhao 1 / 52 Geometry Guoying Zhao 2 / 52 Objectives Introduce the elements of geometry Scalars Vectors Points Develop mathematical operations among

More information

Computer Graphics Geometry and Transform

Computer Graphics Geometry and Transform ! Computer Graphics 2014! 5. Geometry and Transform Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2014-10-11! Today outline Triangle rasterization Basic vector algebra ~ geometry! Antialiasing

More information

Fundamentals of Computer Animation

Fundamentals of Computer Animation Fundamentals of Computer Animation Quaternions as Orientations () page 1 Multiplying Quaternions q1 = (w1, x1, y1, z1); q = (w, x, y, z); q1 * q = ( w1.w - v1.v, w1.v + w.v1 + v1 X v) where v1 = (x1, y1,

More information

What and Why Transformations?

What and Why Transformations? 2D transformations What and Wh Transformations? What? : The geometrical changes of an object from a current state to modified state. Changing an object s position (translation), orientation (rotation)

More information

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z

Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ x + 5y + 7z 9x + 3y + 11z Basic Linear Algebra Linear algebra deals with matrixes: two-dimensional arrays of values. Here s a matrix: [ 1 5 ] 7 9 3 11 Often matrices are used to describe in a simpler way a series of linear equations.

More information

f (Pijk ) V. may form the Riemann sum: . Definition. The triple integral of f over the rectangular box B is defined to f (x, y, z) dv = lim

f (Pijk ) V. may form the Riemann sum: . Definition. The triple integral of f over the rectangular box B is defined to f (x, y, z) dv = lim Chapter 14 Multiple Integrals..1 Double Integrals, Iterated Integrals, Cross-sections.2 Double Integrals over more general regions, Definition, Evaluation of Double Integrals, Properties of Double Integrals.3

More information

Computer Graphics 7: Viewing in 3-D

Computer Graphics 7: Viewing in 3-D Computer Graphics 7: Viewing in 3-D In today s lecture we are going to have a look at: Transformations in 3-D How do transformations in 3-D work? Contents 3-D homogeneous coordinates and matrix based transformations

More information

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects

Mathematics 308 Geometry. Chapter 9. Drawing three dimensional objects Mathematics 308 Geometry Chapter 9. Drawing three dimensional objects In this chapter we will see how to draw three dimensional objects with PostScript. The task will be made easier by a package of routines

More information

Unit 3 Transformations and Clipping

Unit 3 Transformations and Clipping Transformation Unit 3 Transformations and Clipping Changes in orientation, size and shape of an object by changing the coordinate description, is known as Geometric Transformation. Translation To reposition

More information

Polynomials. Math 4800/6080 Project Course

Polynomials. Math 4800/6080 Project Course Polnomials. Math 4800/6080 Project Course 2. The Plane. Boss, boss, ze plane, ze plane! Tattoo, Fantas Island The points of the plane R 2 are ordered pairs (x, ) of real numbers. We ll also use vector

More information

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below:

To graph the point (r, θ), simply go out r units along the initial ray, then rotate through the angle θ. The point (1, 5π 6. ) is graphed below: Polar Coordinates Any point in the plane can be described by the Cartesian coordinates (x, y), where x and y are measured along the corresponding axes. However, this is not the only way to represent points

More information

CS612 - Algorithms in Bioinformatics

CS612 - Algorithms in Bioinformatics Fall 2017 Structural Manipulation November 22, 2017 Rapid Structural Analysis Methods Emergence of large structural databases which do not allow manual (visual) analysis and require efficient 3-D search

More information

2D/3D Geometric Transformations and Scene Graphs

2D/3D Geometric Transformations and Scene Graphs 2D/3D Geometric Transformations and Scene Graphs Week 4 Acknowledgement: The course slides are adapted from the slides prepared by Steve Marschner of Cornell University 1 A little quick math background

More information

Isometries. 1 Identifying Isometries

Isometries. 1 Identifying Isometries Isometries 1 Identifying Isometries 1. Modeling isometries as dynamic maps. 2. GeoGebra files: isoguess1.ggb, isoguess2.ggb, isoguess3.ggb, isoguess4.ggb. 3. Guessing isometries. 4. What can you construct

More information

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52

INTRODUCTION TO COMPUTER GRAPHICS. It looks like a matrix Sort of. Viewing III. Projection in Practice. Bin Sheng 10/11/ / 52 cs337 It looks like a matrix Sort of Viewing III Projection in Practice / 52 cs337 Arbitrary 3D views Now that we have familiarity with terms we can say that these view volumes/frusta can be specified

More information

Viewing and Projection

Viewing and Projection 15-462 Computer Graphics I Lecture 5 Viewing and Projection Shear Transformation Camera Positioning Simple Parallel Projections Simple Perspective Projections [Angel, Ch. 5.2-5.4] January 30, 2003 [Red

More information

Content. Coordinate systems Orthographic projection. (Engineering Drawings)

Content. Coordinate systems Orthographic projection. (Engineering Drawings) Projection Views Content Coordinate systems Orthographic projection (Engineering Drawings) Graphical Coordinator Systems A coordinate system is needed to input, store and display model geometry and graphics.

More information

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective

COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective COMP30019 Graphics and Interaction Three-dimensional transformation geometry and perspective Department of Computing and Information Systems The Lecture outline Introduction Rotation about artibrary axis

More information

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010)

Lecture 4: Transformations and Matrices. CSE Computer Graphics (Fall 2010) Lecture 4: Transformations and Matrices CSE 40166 Computer Graphics (Fall 2010) Overall Objective Define object in object frame Move object to world/scene frame Bring object into camera/eye frame Instancing!

More information

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS

Math 7 Elementary Linear Algebra PLOTS and ROTATIONS Spring 2007 PLOTTING LINE SEGMENTS Math 7 Elementary Linear Algebra PLOTS and ROTATIONS Example 1: Suppose you wish to use MatLab to plot a line segment connecting two points in the xy-plane. Recall that

More information

Camera Projection Models We will introduce different camera projection models that relate the location of an image point to the coordinates of the

Camera Projection Models We will introduce different camera projection models that relate the location of an image point to the coordinates of the Camera Projection Models We will introduce different camera projection models that relate the location of an image point to the coordinates of the corresponding 3D points. The projection models include:

More information

Image warping , , Computational Photography Fall 2017, Lecture 10

Image warping , , Computational Photography Fall 2017, Lecture 10 Image warping http://graphics.cs.cmu.edu/courses/15-463 15-463, 15-663, 15-862 Computational Photography Fall 2017, Lecture 10 Course announcements Second make-up lecture on Friday, October 6 th, noon-1:30

More information

CS452/552; EE465/505. Geometry Transformations

CS452/552; EE465/505. Geometry Transformations CS452/552; EE465/505 Geometry Transformations 1-26-15 Outline! Geometry: scalars, points & vectors! Transformations Read: Angel, Chapter 4 (study cube.html/cube.js example) Appendix B: Spaces (vector,

More information

Chapter 5. Transformations of Objects

Chapter 5. Transformations of Objects Chapter 5. Transformations of Objects Minus times minus is plus, the reason for this we need not discuss W.H.Auden If I eat one of these cakes, she thought, it's sure to make some change in my size. So

More information

5200/7200 Fall 2007 Concurrence theorems for triangles

5200/7200 Fall 2007 Concurrence theorems for triangles 5200/7200 Fall 2007 Concurrence theorems for triangles There are two basic concurrence theorems for triangles that hold in neutral geometry, that of medians and of angle bisectors, but it seems hard to

More information

CSC 305 The Graphics Pipeline-1

CSC 305 The Graphics Pipeline-1 C. O. P. d y! "#"" (-1, -1) (1, 1) x z CSC 305 The Graphics Pipeline-1 by Brian Wyvill The University of Victoria Graphics Group Perspective Viewing Transformation l l l Tools for creating and manipulating

More information

MATHEMATICS FOR ENGINEERING TUTORIAL 5 COORDINATE SYSTEMS

MATHEMATICS FOR ENGINEERING TUTORIAL 5 COORDINATE SYSTEMS MATHEMATICS FOR ENGINEERING TUTORIAL 5 COORDINATE SYSTEMS This tutorial is essential pre-requisite material for anyone studying mechanical engineering. This tutorial uses the principle of learning by example.

More information

Jorg s Graphics Lecture Notes Coordinate Spaces 1

Jorg s Graphics Lecture Notes Coordinate Spaces 1 Jorg s Graphics Lecture Notes Coordinate Spaces Coordinate Spaces Computer Graphics: Objects are rendered in the Euclidean Plane. However, the computational space is better viewed as one of Affine Space

More information

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture

Hello, welcome to the video lecture series on Digital Image Processing. So in today's lecture Digital Image Processing Prof. P. K. Biswas Department of Electronics and Electrical Communications Engineering Indian Institute of Technology, Kharagpur Module 02 Lecture Number 10 Basic Transform (Refer

More information

Affine Transformation. Edith Law & Mike Terry

Affine Transformation. Edith Law & Mike Terry Affine Transformation Edith Law & Mike Terry Graphic Models vs. Images Computer Graphics: the creation, storage and manipulation of images and their models Model: a mathematical representation of an image

More information

SUMMARY. CS380: Introduction to Computer Graphics Varying Variables Chapter 13. Min H. Kim KAIST School of Computing 18/04/26.

SUMMARY. CS380: Introduction to Computer Graphics Varying Variables Chapter 13. Min H. Kim KAIST School of Computing 18/04/26. CS380: Introduction to Computer Graphics Varying Variables Chapter 3 Min H. Kim KAIST School of Computing Rasterization SUMMARY 2 Path from vertex to pixel 3 Clipping coordinates Eye coordinates (projected)

More information

Computer Graphics: Geometric Transformations

Computer Graphics: Geometric Transformations Computer Graphics: Geometric Transformations Geometric 2D transformations By: A. H. Abdul Hafez Abdul.hafez@hku.edu.tr, 1 Outlines 1. Basic 2D transformations 2. Matrix Representation of 2D transformations

More information

CSC418 / CSCD18 / CSC2504

CSC418 / CSCD18 / CSC2504 5 5.1 Surface Representations As with 2D objects, we can represent 3D objects in parametric and implicit forms. (There are also explicit forms for 3D surfaces sometimes called height fields but we will

More information

Background for Surface Integration

Background for Surface Integration Background for urface Integration 1 urface Integrals We have seen in previous work how to define and compute line integrals in R 2. You should remember the basic surface integrals that we will need to

More information

Basics of Computational Geometry

Basics of Computational Geometry Basics of Computational Geometry Nadeem Mohsin October 12, 2013 1 Contents This handout covers the basic concepts of computational geometry. Rather than exhaustively covering all the algorithms, it deals

More information

2D Transformations Introduction to Computer Graphics Arizona State University

2D Transformations Introduction to Computer Graphics Arizona State University 2D Transformations Introduction to Computer Graphics Arizona State University Gerald Farin January 31, 2006 1 Introduction When you see computer graphics images moving, spinning, or changing shape, you

More information

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University

Animating orientation. CS 448D: Character Animation Prof. Vladlen Koltun Stanford University Animating orientation CS 448D: Character Animation Prof. Vladlen Koltun Stanford University Orientation in the plane θ (cos θ, sin θ) ) R θ ( x y = sin θ ( cos θ sin θ )( x y ) cos θ Refresher: Homogenous

More information

For each question, indicate whether the statement is true or false by circling T or F, respectively.

For each question, indicate whether the statement is true or false by circling T or F, respectively. True/False For each question, indicate whether the statement is true or false by circling T or F, respectively. 1. (T/F) Rasterization occurs before vertex transformation in the graphics pipeline. 2. (T/F)

More information