160 likes | 342 Views
Types of Transformations Euclidean rigid body operations: rotation and translation congruence, distance, and parallelism preserved Affine rotation. translation. uniform or differential scale parallelism , and ratio of parallel distances preserved Projective
E N D
Types of Transformations Euclidean rigid body operations: rotation and translation congruence, distance, and parallelism preserved Affine rotation. translation. uniform or differential scale parallelism, and ratio of parallel distances preserved Projective rotation, translation, scale, perspective straight lines preserved
Before the Rasterizer Perspective Space Eye Space World Space persp. divide viewport transform [G1] [G2] … [Gn] [E] [P] clip project xyz1 OpenGL’s “modelView” [G1] …[Gn] affine matrices (for scale, translation, rotation, and shear) [E] world (scene) to eye (camera) matrix [P] OpenGL’s “persp” matrix
Homogeneous Coordinates Homogeneous coordinates have a natural application to computer graphics, ever since their use in a 4x4 matrix by Roberts (1963). Advantages Compact Points at infinity can be represented with finite coordinates Formulas are simpler and more symmetric than Cartesian counterparts
Equivalences from “ordinary” 3D point to homogeneous point (x, y, z) (x, y, z, 1) from 4D homogeneous point to ordinary 3D point (x, y, z, w) (x/w, y/w, z/w)
Möbius introduced a set of “barycentric” coordinates for a point p inside a triangle (a,b,c) (waa, wbb, wcc) w is relatedto area: wa = Aa/(Aa+Ab+Ac). wa+wb+wc = 1
In a homogeneous coordinate system, a point is invariant when scaled. A homogeneous point (x,y,w) may be taken as an ordinary point if it is a ray to the origin is intersected by the w = 1 plane.
Image point (x’, y’) is computed from the object point (x, y, z), effecting similar triangles: y’/y = D/z and x’/x = D/z, or (x’, y’) = (xD/z, yD/z). side view The division by z is known as the perspective divide.
Introducing a non-zero term into the fourth column does not affect x’ and y’, but z’ becomes D-D/z. For z =1, z’ = 0, and for z = ∞, z’ = D.
OpenGL uses a right-handed coordinate system, right-handed rotations, and column-major matrices That is, OpenGL expects an argument GLdouble *m to point to a series of doubles, the first four (m[0][0], m[0][1], m[0][2], m[0][3]) representing the first column of the matrix, the second four the second column, etc.
To Infinity and Beyond! in Eye Space, eye is at the origin, facing to the right in Perspective Space, eye is at (0,0,+inf), facing right
3D Perspective woodcuts by Albrecht Durer 1525 self-potrait 1500
perspective is a depth cue for monocular and binocular vision
For Planar Perspective Projection In 3D, a straight line is given by a point and a direction; that is, a line is described parametrically by a set of points P: P = B+tV. That is, rewriting the first: t = (x-bx)/vx andrewriting the third: z = bz+(x-bx)vz/vx Thus, on a line, z is linearly related to x (and to y) x = bx+tvx y = by+tvy z = bz+tvz
2 by 2 linear transformation gives x’ = a1x+b1y y’ = a2x+b2y 3 by 3 gives x’ = a1x+b1y+c1z y’ = a2x+b2y+c2z z’ = a3x+b3y+c3z 4 by 4 homogeneous affine gives x’ = a1x+b1y+c1z+d1 y’ = a2x+b2y+c2z+d2 z’ = a3x+b3y+c3z+d3 w’ = 1 this is a linear combination of x, y, and z, and therefore z’ is linearly related to x’ (and to y’, and to z) 4 by 4 perspective, however, gives this is ‘linear rational’ - z’ is no longer linearly related to z, but because the denominators are the same for x’, y’, and z’, z’ remains linearly related to x’ and to y’ x’ = (a1x+b1y+c1z+d1)/(ex+fy+gz+h) y’ = (a2x+b2y+c2z+d2)/(ex+fy+gz+h) z’ = (a3x+b3y+c3z+d3)/(ex+fy+gz+h) Thus, a straight line in 3D yields a straight line under planar perspective projection (and thank goodness for that).