Perspective Projection Matrix | Camera Projection Matrix

Global Parameters

Enter intrinsic parameters for the camera
     
     

θx and θy are the angles of view along the x and y axes

Skew : s = 0    Principal point : (x0, y0) = (0, 0)

Enter a set of 3D world points for projection
(The view frustum is in the negative portion of the z axis)
Project basic structures onto the screen
Step 1: First rotate the points around respective axes

Default rotation order: first z then y then x

Rotate x: 0

0
2

Rotate y: 0

0
2

Rotate z: 0

0
2
Step 2: Then translate the points in respective directions

Translate x

-10
10

Translate y

-10
10

Translate z

-10
10

Perspective Projection in Graphics

Rotation X Matrix
1 0 0 0 1 0 0 0 1
·
Rotate Y Matrix
1 0 0 0 1 0 0 0 1
·
Rotate Z Matrix
1 0 0 0 1 0 0 0 1
Flattens the 3D points onto the 2D XY plane by setting z to 0
1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
Transforms canonical perspective view frustum into canonical parallel view frustum
1 0 0 0 0 1 0 0 0 0 far/far - near -1 0 0 near/far-near 0
Transforms perspective view frustum into canonical perspective view frustum
1/tan(θx/2) 0 0 0 0 1/tan(θy/2) 0 0 0 0 1 0 0 0 0 1
Moves the far clipping plane to z = -1
-1/far 0 0 0 0 -1/far 0 0 0 0 -1/far 0 0 0 0 1
Transforms 3D world coordinates to camera coordinates
rx1 ry1 rz1 0 rx2 ry2 rz2 0 rx3 ry3 rz3 0 tx ty tz 1
1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
·
1 0 0 0 0 1 0 0 0 0 1.05 -1 0 0 0.05 0
·
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
·
0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1
·
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
=
Perspective Projection Matrix
0.1 0 0 0 0 0.1 0 0 0 0 0 -0.1 0 0 0 0
Perspective Projection Matrix
0.1 0 0 0 0 0.1 0 0 0 0 0 -0.1 0 0 0 0
·
World Points
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1

drop z →   

Projected Points
0 0 1 0 0 1 0 0 1 0 0 1

1 ·
Point 1
0 0 1
, 1 ·
Point 2
0 0 1
, 1 ·
Point 3
0 0 1
, 1 ·
Point 4
0 0 1

The coordinates can be inaccurate when the far clipping plane has a very negative z value.

Intrinsic Matrix
1 0 0 0 1 0 0 0 1
·
Extrinsic Matrix
1 0 0 0 1 0 0 0 1 0 0 0
=
Camera Projection Matrix
1 0 0 0 1 0 0 0 1 0 0 0

The extrinsic matrix is the same as the first 3 rows of the transformation matrix, while the intrinsic matrix is the product of the perspective matrix and the scaling matrix except for the 3rd row.

Camera Projection in Vision

Transforms points in the camera coordinates to the 2D image coordinates
fx 0 0 s fy 0 x0 y0 1
Transforms 3D world coordinates to camera coordinates
rx1 ry1 rz1 rx2 ry2 rz2 rx3 ry3 rz3 tx ty tz
1 0 0 0 1 0 0 0 1
·
1 0 0 0 1 0 0 0 1 0 0 0
=
Camera Projection Matrix
1 0 0 0 1 0 0 0 1 0 0 0
Camera Projection Matrix
1 0 0 0 1 0 0 0 1 0 0 0
·
World Points
0 0 0 1 0 0 0 1 0 0 0 1 0 0 0 1

----------------> Invert the
upside-down image

Projected Points
0 0 1 0 0 1 0 0 1 0 0 1

1 ·
Point 1
0 0 1
, 1 ·
Point 2
0 0 1
, 1 ·
Point 3
0 0 1
, 1 ·
Point 4
0 0 1

Note! The inversion step exists only in camera projection because its z are negative before dehomogenization, while the z in perspective projection have been negated by the projection matrix.

Orthographic Projection Matrix
1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
·
Projection Matrix
1 0 0 0 0 1 0 0 0 0 1 -1 0 0 0 0
·
Perspective Matrix
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
·
Scaling Matrix
0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1
·
Transformation Matrix
1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
=
Perspective Projection Matrix
0.1 0 0 0 0 0.1 0 0 0 0 0 -0.1 0 0 0 0

The transformation matrix is equal to the extrinsic matrix except for their shape. The projection matrix and scaling matrix are not unique, because the clipping points and scaling factors are not taken into account in the intrinsic matrix. The perspective matrix corresponds with the intrinsic matrix.


Created by Wanjia Fu, Brown University, Summer 2023.