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 if it does not, called simple polygon Convex vs. Concave Polygons Convex: For every pair of points in the polygon, the line between them is fully contained in the polygon. Concave: Not convex: some two points in the polygon are joined by a line not fully contained in the polygon. Andries van Dam September 14, 2000 Transformation 1/17
2D Object Definition (2/3) Special polygons Circles Consist of all points equidistant from one predetermined point (the center) (radius) r = c, where c is a constant On a Cartesian grid with center of circle at origin equation is r 2 = x 2 + y 2 Andries van Dam September 14, 2000 Transformation 2/17
2D Object Definition (3/3) Circle as polygon Informally: a regular polygon with > 15 sides (Aligned) Ellipses A circle scaled along the x or y axis Example: height, on y-axis, remains 3 while length, on x-axis, changes from 3 to 6 Andries van Dam September 14, 2000 Transformation 3/17
2D to 3D Object Definition Vertices in motion ( Generative object description ) Line is drawn by tracing path of a point as it moves (one dimensional entity) Square drawn by tracing vertices of a line as it moves perpendicularly to itself (two dimensional entity) Cube drawn by tracing paths of vertices of a square as it moves perpendicularly to itself (three-dimensional entity) Circle drawn by swinging a point at a fixed length around a center point Andries van Dam September 14, 2000 Transformation 4/17
Translation Component-wise addition of vectors v = v + t where and x = x + dx y = y + dy To move polygons: just translate vertices (vectors) and then redraw lines between them Preserves lengths (isometric) Preserves angles (conformal) Andries van Dam September 14, 2000 Transformation 5/17
Component-wise scalar multiplication of vectors v = Sv where Scaling and x = s x x y = s y y Does not preserve lengths Does not preserve angles (except when scaling is uniform) Andries van Dam September 14, 2000 Transformation 6/17
Rotation Rotation of vectors through an angle θ v = R θ v where and x = x cos θ y sin θ y = x sin θ + y cos θ Proof is by double angle formula Preserves lengths and angles Note: house shifts position relative to the origin Andries van Dam September 14, 2000 Transformation 7/17
Rotation and Scale are Relative to Origin Suppose object is not centered at origin? Solution: move it to the origin, then scale and/or rotate, then move it back. We d like to be able to compose successive transformations Andries van Dam September 14, 2000 Transformation 8/17
Homogenous Coordinates Translation, scaling and rotation are expressed (nonhomogeneously) as: Composition is difficult to express, since translation not expressed as a matrix multiplication Homogeneous coordinates allow all three to be expressed homogeneously, allowing composition via multiplication by 3x3 matrices w is 1 for affine transformations in graphics Andries van Dam September 14, 2000 Transformation 9/17
What is? P 2d is intersection of line determined by P h with the w = 1 plane So an infinite number of points correspond to (x,y,1) : they constitute the whole line (tx,ty,tw) Andries van Dam September 14, 2000 Transformation 10/17
Homogeneous Coordinate Transformations (1/2) For points written in homogeneous translation, scaling and rotation relative to the origin are expressed homogeneously as: Andries van Dam September 14, 2000 Transformation 11/17
Homogeneous Coordinate Transformations (2/2) Consider The 2 x 2 submatrix columns: are unit vectors (length=1) are perpendicular (dot product=0) are vectors into which X-axis and Y-axis rotate (are images of x and y unit vectors) The 2 x 2 submatrix rows: are unit vectors are perpendicular rotate into X-axis and Y-axis (are pre-images of x and y unit vectors) These properties of rows and columns preserve lengths and angles of the original geometry. Therefore, this matrix is a rigid body transformation Andries van Dam September 14, 2000 Transformation 12/17
Translate [1,3] by [7,9] Examples Scale [2,3] by 5 in the x direction and 10 in the Y direction Rotate [2,2] by 90 0 Andries van Dam September 14, 2000 Transformation 13/17
The Translation Matrix is very Useful With the T matrix from above, we can avoid the unwanted translation introduced when we scale or rotate an object not centered at the origin. This is done by translating the object to the origin, performing the scale or rotate operation, and then translating the object back. Here s an example. Andries van Dam September 14, 2000 Transformation 14/17
3D Basic Transformations (1/2) (right-handed coordinate system) Translation Scaling Andries van Dam September 14, 2000 Transformation 15/17
3D Basic Transformations (2/2) Rotation about X-axis (right-handed coordinate system) Rotation about Y-axis Rotation about Z-axis Andries van Dam September 14, 2000 Transformation 16/17
3D Homogeneous Coordinate Example Translation matrix Andries van Dam September 14, 2000 Transformation 17/17