3D projection

From Wikipedia, the free encyclopedia

(Redirected from Perspective transform)
Jump to: navigation, search

A 3D projection is a mathematical transformation used to project three dimensional points onto a two dimensional plane[1]. As most current methods for displaying graphical data are based on two dimensional media, the use of 3D projection is widespread, especially in computer graphics, engineering and drafting. Several common projections are described below.

Contents

Orthographic projections are a small set of transforms often used to show profile, detail or precise measurements of a three dimensional object. Common names for orthographic projections include plan, cross-section, birds-eye, and elevation.

The normal of the viewing plane (the camera direction) is always parallel to one of the 3D axes making the mathematical transformation very simple. To project the 3D point ax, ay, az onto the 2D point bx, by using an Orthographic projection parallel to the y axis(Profile view), the following equation can be used:

bx = sxax + cx
by = szaz + cz

Where the vector s is an arbitrary scale factor, and c is an arbitrary offset. These constants are optional, and can be used to properly align the viewport. The projection can be shown using Matrix notation (introducing a temporary vector d for clarity)


 \begin{bmatrix}
   {d_x }  \\
   {d_y }  \\
 \end{bmatrix} = \begin{bmatrix}
   1 & 0 & 0  \\
   0 & 0 & 1  \\
\end{bmatrix}\begin{bmatrix}
   {a_x }  \\
   {a_y }  \\
   {a_z }  \\
\end{bmatrix}

 \begin{bmatrix}
   {b_x }  \\
   {b_y }  \\
\end{bmatrix} = \begin{bmatrix}
   {s_x } & 0  \\
   0 & {s_y }  \\
\end{bmatrix}\begin{bmatrix}
   {d_x }  \\
   {d_y }  \\
\end{bmatrix} + \begin{bmatrix}
   {c_x }  \\
   {c_y }  \\
\end{bmatrix}

The perspective projection requires greater definition. A conceptual aid to understanding the mechanics of this projection involves treating the 2D projection as being viewed through a camera viewfinder. The camera's position, orientation, and field of view control the behaviour of the projection transformation. The following variables are defined to describe this transformation:

  • \mathbf{a}_{x,y,z} - a point in 3D space.
  • \mathbf{c}_{x,y,z} - the location of the camera.
  • \mathbf{\theta}_{x,y,z} - The rotation of the camera. When \mathbf{c}_{x,y,z}=<0,0,0>, and \mathbf{\theta}_{x,y,z}=<0,0,0>, the 3D vector <1,2,0> is projected to the 2D vector <1,2>.
  • \mathbf{e}_{x,y,z} - the viewer position in camera space. [2]

Which results in:

  • \mathbf{b}_{x,y} - the 2D projection of \mathbf{a}.

First, we define a point \mathbf{d}_{x,y,z} as a translation of point \mathbf{a} into a coordinate system defined by \mathbf{c}. This is achieved by subtracting \mathbf{c} from \mathbf{a} and then applying a vector rotation matrix using -\mathbf{\theta} to the result. This transformation is often called a camera transform: [3] [4] [5]


\begin{bmatrix}
   \mathbf{d}_x \\
   \mathbf{d}_y \\
   \mathbf{d}_z \\
\end{bmatrix}=\begin{bmatrix}
   1 & 0 & 0  \\
   0 & {\cos -\mathbf{\theta}_x } & {\sin -\mathbf{\theta}_x }  \\
   0 & { - \sin -\mathbf{\theta}_x } & {\cos -\mathbf{\theta}_x }  \\
\end{bmatrix}\begin{bmatrix}
   {\cos -\mathbf{\theta}_y } & 0 & { - \sin -\mathbf{\theta}_y }  \\
   0 & 1 & 0  \\
   {\sin -\mathbf{\theta}_y } & 0 & {\cos -\mathbf{\theta}_y }  \\
\end{bmatrix}\begin{bmatrix}
   {\cos -\mathbf{\theta}_z } & {\sin -\mathbf{\theta}_z } & 0  \\
   { - \sin -\mathbf{\theta}_z } & {\cos -\mathbf{\theta}_z } & 0  \\
   0 & 0 & 1  \\
\end{bmatrix}\left( {\begin{bmatrix}
   \mathbf{a}_x  \\
   \mathbf{a}_y  \\
   \mathbf{a}_z  \\
\end{bmatrix} - \begin{bmatrix}
   \mathbf{c}_x  \\
   \mathbf{c}_y  \\
   \mathbf{c}_z  \\
\end{bmatrix}} \right)

Or, for those less comfortable with matrix multiplication:


\begin{array}{lcl}
	d_x &= &\cos \theta_y\cdot(\sin \theta_z\cdot(a_y-c_y)+\cos \theta_z\cdot(a_x-c_x))-\sin \theta_y\cdot(a_z-c_z) \\
	d_y &= &\sin \theta_x\cdot(\cos \theta_y\cdot(a_z-c_z)+\sin \theta_y\cdot(\sin \theta_z\cdot(a_y-c_y)+\cos \theta_z\cdot(a_x-c_x)))+\cos \theta_x\cdot(\cos \theta_z\cdot(a_y-c_y)-\sin \theta_z\cdot(a_x-c_x)) \\
	d_z &= &\cos \theta_x\cdot(\cos \theta_y\cdot(a_z-c_z)+\sin \theta_y\cdot(\sin \theta_z\cdot(a_y-c_y)+\cos \theta_z\cdot(a_x-c_x)))-\sin \theta_x\cdot(\cos \theta_z\cdot(a_y-c_y)-\sin \theta_z\cdot(a_x-c_x)) \\
\end{array}

This transformed point can then projected onto the 2D plane using the formula (here, x/y is used as the projection plane, literature also may use x/z):[6]


\begin{array}{lcl}
 \mathbf{b}_x &= &(\mathbf{d}_x - \mathbf{e}_x) (\mathbf{e}_z / \mathbf{d}_z) \\
 \mathbf{b}_y &= &(\mathbf{d}_y - \mathbf{e}_y) (\mathbf{e}_z / \mathbf{d}_z) \\
\end{array}

Or again in matrix form:


\begin{bmatrix}
   \mathbf{f}_x \\
   \mathbf{f}_y \\
   \mathbf{f}_z \\
   \mathbf{f}_w \\
\end{bmatrix}=\begin{bmatrix}
   1 & 0 & 0 & -\mathbf{e}_x \\
   0 & 1 & 0 & -\mathbf{e}_y \\
   0 & 0 & 1 & 0 \\
   0 & 0 & 1/\mathbf{e}_z & 0 \\
\end{bmatrix}\begin{bmatrix}
   \mathbf{d}_x  \\
   \mathbf{d}_y  \\
   \mathbf{d}_z  \\
   1 \\
\end{bmatrix}

and


\begin{array}{lcl}
 \mathbf{b}_x &= &\mathbf{f}_x / \mathbf{f}_w \\
 \mathbf{b}_y &= &\mathbf{f}_y / \mathbf{f}_w \\
\end{array}

The distance of the camera plane to the viewer, \mathbf{e}_z, directly relates to the field of view, where \alpha=2 \cdot \tan^{-1}(1/\mathbf{e}_z) is the viewed angle.

Subsequent clipping and scaling operations may be necessary to map the 2D plane onto any particular display media.

Image:Perspective Transform Diagram.png

To determine which screen x coordinate corresponds to a point at Ax,Az multiply the point coordinates by:

screen\ x\ coordinate\ (Bx)\ =\ model\ x\ coordinate\ (Ax) \times \frac{distance\ from\ eye\ to\ screen\ (Bz)}{distance\ from\ eye\ to\ point\ (Az)}

the same works for the screen y coordinate:

screen\ y\ coordinate\ (By)\ =\ model\ y\ coordinate\ (Ay) \times \frac{distance\ from\ eye\ to\ screen\ (Bz)}{distance\ from\ eye\ to\ point\ (Az)}

Other common 3D projections include:

  1. ^ Kenneth C. Finney (2004). 3D Game Programming All in One. Thomson Course, 93. ISBN 159200136X. 
  2. ^ Ingrid Carlbom, Joseph Paciorek (Dec. 1978). Planar Geometric Projections and Viewing Transformations. ACM Computing Surveys (CSUR), p.465-502. DOI:10.1145/356744.356750. 
  3. ^ Riley, K F (2006). Mathematical Methods for Physics and Engineering. Cambridge University Press, 931. DOI:10.2277/0521679710. ISBN 0521679710. 
  4. ^ Riley, K F (2006). Mathematical Methods for Physics and Engineering. Cambridge University Press, 942. DOI:10.2277/0521679710. ISBN 0521679710. 
  5. ^ Goldstein, Herbert (1980). Classical Machanics 2nd Edn., 146-148. ISBN 0201029189. 
  6. ^ Sonka, M; Hlavac, V & Boyle, R (1995), Image Processing, Analysis & Machine Vision 2nd Edn., Chapman and Hall, pp. 14, ISBN 0412455706
Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.