Projection n n Projection the transformation of points

  • Slides: 31
Download presentation
Projection n n Projection - the transformation of points from a coordinate system in

Projection n n Projection - the transformation of points from a coordinate system in n dimensions to a coordinate system in m dimensions where m<n. We will be talking about projections from 3 D to 2 D, where the 3 D space represents a world coordinate system and the 2 D space is a window which is mapped to a screen viewport.

Specifying a Projection n Two things must be specified n n Projection plane and

Specifying a Projection n Two things must be specified n n Projection plane and a center of projection. A 2 D coordinate system onto which the 3 D image is to be projected. We’ll call this the VRP for view reference plane. Center of projection n A point in space which serves as an end point for projectors. We’ll refer to this point as the COP. It is also called a PRP for a projection reference point.

Projectors n Projectors - a ray originating at the center of projection and passing

Projectors n Projectors - a ray originating at the center of projection and passing through a point to be projected. Here is an example of a projection:

Parallel Projection n A simple case of a projection is if the projectors are

Parallel Projection n A simple case of a projection is if the projectors are all in parallel. n What does this imply about the COP?

Direction of Projection n We can’t specify the COP for parallel projection n We’ll

Direction of Projection n We can’t specify the COP for parallel projection n We’ll use Direction of Project (DOP) instead

Some Trivia n Planar geometric projection n n A projection onto a planar surface

Some Trivia n Planar geometric projection n n A projection onto a planar surface (planar) using straight lines (geometric). Foreshortening n Varying lengths of lines due to angle of presentation and/or distance from center of projection. Applies to both parallel and perspective projections.

Orthographic Projections n Orthographic projection n n Elevation n n parallel projection with the

Orthographic Projections n Orthographic projection n n Elevation n n parallel projection with the direction of projection and the projection plane normal parallel. an orthographic projection in which the view plane normal is parallel to an axis. The three elevations n n n front-elevation top-elevation (plan-elevation) side-elevation.

Axonometric orthographic projections n n Use projection planes which are not normal to an

Axonometric orthographic projections n n Use projection planes which are not normal to an axis. They show more than one face of an object at a time. They induce uniform foreshortening unrelated to depth. AOP preserves parallelism of lines. It does not preserve angles.

Isometric projection n Axonometric orthographic projection where the projection plane normal (and the direction

Isometric projection n Axonometric orthographic projection where the projection plane normal (and the direction of projection) makes identical angles with each principle axis. How many of these are there?

Oblique Projection n Oblique projection n the projection plane normal and the direction of

Oblique Projection n Oblique projection n the projection plane normal and the direction of projection are at angles to each other. DOP VPN

Cavalier Projection n Why? An Oblique projection n DOP is at 45 degree angle

Cavalier Projection n Why? An Oblique projection n DOP is at 45 degree angle to VPN Lines parallel to any axis are foreshortened equally. Lines parallel to the z axis appear at an angle a, which is dependent upon the direction of projection. Two common projections have a as 45° and 30°. 45 o 30 o

Cavalier Projection Angles DOP VPN

Cavalier Projection Angles DOP VPN

Cabinet projection n Oblique projection n n projection plane normal is at an arctan(2)

Cabinet projection n Oblique projection n n projection plane normal is at an arctan(2) = 63. 4° degree angle to the projection plane. (typically projecting onto the x, y plane) Lines parallel to the axis defining the projection plane are foreshortened equally. Lines parallel to the projection plane normal are halved!

Cabinet Projection DOP 63. 4 o VPN

Cabinet Projection DOP 63. 4 o VPN

Parallel Projection n After transforming the object to the eye space, parallel projection is

Parallel Projection n After transforming the object to the eye space, parallel projection is relative easy – we could just drop the Z Xp = x Yp = y Zp = -d n We actually want to keep Z – why? (Xp, Yp) y z x (x, y, z)

Parallel Projection (2) n Open. GL maps (projects) everything in the visible volume into

Parallel Projection (2) n Open. GL maps (projects) everything in the visible volume into a canonical view volume (xmax, ymax, -far) (xmin, ymin, -near) gl. Ortho(xmin, xmax, ymin, ymax, near, far) (1, 1, -1) (-1, 1) Canonical View Volume

Parallel Projection (3) n Transformation sequence: 1. Translation (M 1): (-near = zmax, -far

Parallel Projection (3) n Transformation sequence: 1. Translation (M 1): (-near = zmax, -far = zmin) -(xmax+xmin)/2, -(ymax+ymin)/2, -(zmax+zmin)/2 2. Scaling (M 2): 2/(xmax-xmin), 2/(ymax-ymin), 2/(zmax-zmin) M 2 x M 1 = 2/(xmax-xmin) 0 0 - (xmax+xmin)/(xmax-xmin) 0 2/(ymax-ymin) 0 - (ymax+ymin)/(ymax-ymin) 0 0 2/(zmax-zmin) -(zmax+zmin)/(zmax-zmin) 0 0 0 1

Perspective Projection n Perspective projections have projectors at angles to each other radiating from

Perspective Projection n Perspective projections have projectors at angles to each other radiating from a center of projection. n Parallel lines not parallel to the projection plane will not appear parallel in the projection.

Vanishing Points n If not parallel? n n If the lines are not parallel

Vanishing Points n If not parallel? n n If the lines are not parallel anymore, they must meet somewhere. In 3 D space that point will be at infinity and is referred to as a vanishing point. There an infinite number of vanishing points. Axis vanishing points n Lines parallel to one of the major axis come to a vanishing point, these are called axis vanishing points. Only three axis vanishing points in 3 D space.

Center of Projection in Open. GL always puts the center of projection at 0,

Center of Projection in Open. GL always puts the center of projection at 0, 0, 0 n n The projection plane is at z = -d This is sometimes called the “focal length” or “f”

gl. Frustum(left, right, bottom, top, znear, zfar) Frustums n The region we can see

gl. Frustum(left, right, bottom, top, znear, zfar) Frustums n The region we can see is called the frustum (right, top, -znear) (0, 0, 0) -zfar (left, bottom, -znear) znear and zfar are positive

glu. Perspective n How do we get from: n n glu. Perspective(fovy, aspect, znear,

glu. Perspective n How do we get from: n n glu. Perspective(fovy, aspect, znear, zfar) To n gl. Frustum(left, right, bottom, top, znear, zfar)

fov to near frustum (x, y, -znear) -z

fov to near frustum (x, y, -znear) -z

Projection Structure Pinhole Camera Model of P(x, y, z) Projection y x Proportional! P'(x',

Projection Structure Pinhole Camera Model of P(x, y, z) Projection y x Proportional! P'(x', y', z') -d -z

Matrix for Perspective Projection? n n n We need division to do projection! But,

Matrix for Perspective Projection? n n n We need division to do projection! But, matrix multiplication only does multiplication and addition What about:

Homogenous Coordinates (again) n A 3 D homogeneous coordinate: n n n (x, y,

Homogenous Coordinates (again) n A 3 D homogeneous coordinate: n n n (x, y, z, w) We had been saying that w is 1 But – n n (x, y, z, w) corresponds to (x/w, y/w, z/w) Dividing by w is called homogenizing If w=1, x, y, z are unchanged. But, if w=-z/d? n (x/(-z/d), y/(-z/d), z/(-z/d)) = (-dx/z, -dy/z, -d)

The Entire Viewing Process n n Rotate world so that the COP is at

The Entire Viewing Process n n Rotate world so that the COP is at 0, 0, 0 and DOP is parallel to the Z axis Apply perspective projection Homogenize Viewport transformation

Viewport Transformation (Window to Viewport) n Window n n n Area of the projection

Viewport Transformation (Window to Viewport) n Window n n n Area of the projection plane Typically some normalized area with 0, 0 in the center Viewport n n Area of the computer display window Example: n (0, 0) to (640, 480)

Window to Viewport Example n Assume Window (-1, -1) to (1, 1) n n

Window to Viewport Example n Assume Window (-1, -1) to (1, 1) n n Open. GL calls these normalized device coordinates Viewport (0, 0) to (640, 480) n Open. GL calls these window coordinates

Perspective Projection (6) n x’ Final Projection Matrix: 2 N/(xmax-xmin) y’ = 0 z’

Perspective Projection (6) n x’ Final Projection Matrix: 2 N/(xmax-xmin) y’ = 0 z’ 0 w’ 0 0 2 N/(ymax-ymin) (xmax+xmin)/(xmax-xmin) 0 x 0 y -2 F*N/(F-N) z 0 1 (ymax+ymin)/(ymax-ymin) 0 -(F + N)/(F-N) 0 -1 gl. Frustum(xmin, xmax, ymin, ymax, N, F) N = near plane, F = far plane

or po di rt na te s V indo ie w wt po o

or po di rt na te s V indo ie w wt po o V co iew rt ce vi de D ) (2 es es di na t co or e en iz og H om rd in at es Object Coordinates W ed iz al or m N Pr oj Cl M ect ip co atrix ion o rd in at M od Ey e c Ma elvi oo trix ew Within Open. GL gl. Begin(GL_POLYGON); gl. Vertex 3 dv(a); gl. Vertex 3 dv(b); gl. Vertex 3 dv( c); gl. End();