|
|||||||||
A model for perspective projection |
|||||||||
This information is based upon "Practical Techniques for Producing 3D Graphical Images" by Tom Foley and Greg Nielson. The model will be a pin-hole camera with zoom capability, which takes a square photograph. The parameters that define the position and attitude of the camera are: F : FROM point = A point in 3D world coordinates representing the position of the camera. This will be the centre for the perspective projection. A : AT point = A point in 3D world coordinates at which the camera is aimed, thus the vector A-F is the line of sight. The "film" or projection plane is perpendicular to this vector. U : UP vector = A vector in 3D-world cordinates which defines the direction up in world coodinates. The camera is positioned so that the image of the UP vector on the film will be pointing up on the photograph. v : View angle = An angle which specifies the field of view. This value directly affects the distance of the plane of projection (film) from F. Need a viewport in NDC coordinates. The viewport determines where the pin-hole camera's "photograph" is to be displayed on the screen. To avoid distortion of the image, the viewport should be square. Restrictions on F, A and U:
Zooming effects:You can enlarge an image by reducing the angle of view (moving the film farther from the pin-hole). Increasing the view angle makes the image smaller. Viewing angles between 40 degrees and 60 degrees give the most realistic view. An object in world coordinate space is typically specified as a set of 3D (X,Y,Z) vertices, and a set of edges connecting those vertices. In order to produce a 2D screen image of the object, the 3D coordinates of each vertex must first be transformed to 2D integer screen coordinates. This is called theviewing transformation. The viewing transformation is usually done in 2 steps:
Eye coordinates are defined in a left handed coordinate system. We want to transform the world coordinates to eye coordinates in such a way that F ends up at the origin in the eye coordinate system, A ends up on the positive Z-axis, and the UP vector ends up in the positive Y-Z plane. World coordinate transformation to eye coordinates can be done in 5 steps:
Each of the 3 rotations can be accomplished by multiplying the (X,Y,Z) coordinates of each vertex by a 3x3 matrix, followed by the final negation to convert right-handed to left-handed coordinates. The eye coordinate of a world coordinate vertex is: Pe is the 3D eye coordinate point we want. Pw is the 3D world coordinate vertex. F is the from point. V is the 3x3 matrix. Need to calculate the 9 terms of the matrix V (which is orthogonal). In eye coordinates, the Z-axis is the line-of-sight. So we get:
The world coordinate transformation of the eye coordinate X axis is the cross product of the line-of-sight and the UP vector.
The calculation of the vector, which transforms to the Y axis, is the cross product between a and c.
Converting in eve coordinates into 2D coordinates:
|
|||||||||
|
|||||||||
|