Class PerspectiveNormalizeMatrix
- java.lang.Object
-
- renderer.scene.PerspectiveNormalizeMatrix
-
public final class PerspectiveNormalizeMatrix extends Object
We use two steps to transform the camera's configurable perspective view volume into the standard perspective view volume. The first step skews the camera's view volume so that its center line is the negative z-axis (this takes an asymmetric view volume and makes it symmetric). The second step scales the skewed view volume so that it intersects the image plane,z = -1
, with corners(-1, -1, -1)
and(+1, +1, -1)
(this gives the symmetric view volume a 90 degree field-of-view).Let us derive the matrix for transforming the camera's perspective view volume into the standard perspective view volume. Suppose the camera's perspective view volume has an asymmetrical cross section in the yz-plane that is determined by the top and bottom points
(t, -1)
and(b, -1)
. The center line of this cross section is determined by the point((t+b)/2, -1)
. We want to skew the yz-plane in the y-direction along the z-axis so that the field-of-view's center line becomes the z-axis. So we need to solve this matrix equation for the value of the skew factors
.
This simplifies to the equation[ 1 s ] * [ (t+b)/2 ] = [ 0 ] [ 0 1 ] [ -1 ] [ -1 ]
(t + b)/2 - s = 0, s = (t + b)/(2).
A similar calculation can be made for skewing the field-of-view in the xz-plane.
Once the field-of-view in the yz-plane has been made symmetric with respect to the z-axis, we want to scale it in the y-direction so that the scaled field-of-view has an angle at the origin of 90 degrees. We need to scale the point
((t-b)/2, -1)
to the point(1, -1)
(and the point((b-t)/2, -1)
to the point(-1, -1)
). So we need to solve this matrix equation for the value of the scale factors
.
This simplifies to the equation[ s 0 ] * [ (t-b)/2 ] = [ 1 ] [ 0 1 ] [ -1 ] [ -1 ]
s * (t - b)/2 = 1, s = 2/(t - b).
A similar calculation can be made for scaling the skewed field-of-view in the xz-plane.
The following matrix skews the camera's view volume along the z-axis so that the transformed view volume will be centered on the negative z-axis.
The following matrix scales the skewed view volume so that it will be 2 units wide and 2 units tall at the image plane[ 1 0 (r+l)/(2) 0 ] [ 0 1 (t+b)/(2) 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ]
z = -1
.
The matrix product looks like this.[ 2/(r-l) 0 0 0 ] [ 0 2/(t-b) 0 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ]
This product matrix transforms the camera's configurable perspective view volume into the standard normalized perspective view volume whose intersection with the image plane,[ 1 0 (r+l)/2 0 ] [ 2/(r-l) 0 0 0 ] [ 0 1 (t+b)/2 0 ] * [ 0 2/(t-b) 0 0 ] [ 0 0 1 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ] [ 0 0 0 1 ] [ 2/(r-l) 0 (r+l)/(r-l) 0 ] = [ 0 2/(t-b) (t+b)/(t-b) 0 ] [ 0 0 1 0 ] [ 0 0 0 1 ]
z = -1
, hasleft = -1
,right = +1
,bottom = -1
, andtop = +1
.
-
-
Constructor Summary
Constructors Constructor Description PerspectiveNormalizeMatrix()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Matrix
build(double l, double r, double b, double t)
This is a static factory method.
-
-
-
Constructor Detail
-
PerspectiveNormalizeMatrix
public PerspectiveNormalizeMatrix()
-
-
Method Detail
-
build
public static Matrix build(double l, double r, double b, double t)
This is a static factory method.Construct the
Matrix
that transforms from theCamera
's perspective view coordinate system to the normalized perspective camera coordinate system.- Parameters:
l
- left edge of view rectangle in the image plane z = -1r
- right edge of view rectangle in the image plane z = -1b
- bottom edge of view rectangle in the image plane z = -1t
- top edge of view rectangle in the image plane z = -1- Returns:
- a new
Matrix
object containing the perspective normalization matrix
-
-