ct4510: computer graphics projections › courses › 2018_spring_cg › 2018_03... ·...
TRANSCRIPT
![Page 1: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/1.jpg)
CT4510: Computer Graphics
ProjectionsBOCHANG MOON
![Page 2: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/2.jpg)
Graphics PipelineModeling
Transformation
Illumination
Viewing Transformation
Clipping
Projection
Rasterization
Display
![Page 3: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/3.jpg)
Sequence of Spaces and Transformations
Object space
Modeling transformation
World space
Viewingtransformation
Eye (camera) space
![Page 4: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/4.jpg)
Sequence of Spaces and Transformations
Object space
Modeling transformation
World space
Viewingtransformation
Eye (camera) space
ProjectionTransformation
Canonical view volume (normalized device coordinates)
ViewportTransformation
Screen space
![Page 5: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/5.jpg)
Canonical View Volume
(-1,-1,-1)
(1,1,1)
x
yz
![Page 6: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/6.jpg)
Viewport Transformation• Primitives (or line segments) within the canonical view volume will be
mapped to the image
(-1,-1,-1)
(1,1,1)
x
yz
Image (or window on the screen)
𝑛𝑛𝑥𝑥 pixels
𝑛𝑛𝑦𝑦 pixels
![Page 7: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/7.jpg)
Viewport Transformation• Ignore the z-coordinates of points for now◦ In practice, we need the z-coordinates and this will be covered later.
• Map the square −1,1 2to the rectangle −0.5,𝑛𝑛𝑥𝑥 − 0.5 × [−0.5,𝑛𝑛𝑦𝑦 − 0.5]
(-1,-1,-1)
(1,1,1)
x
yz
Image (or window on the screen)
𝑛𝑛𝑥𝑥 pixels
𝑛𝑛𝑦𝑦 pixels
![Page 8: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/8.jpg)
Raster Image (again)• Ignore the z-coordinates of points for now◦ In practice, we need the z-coordinates and this will be covered later.
• Map the square −1,1 2to the rectangle −0.5,𝑛𝑛𝑥𝑥 − 0.5 × [−0.5,𝑛𝑛𝑦𝑦 − 0.5]
• Where do we need to locate pixels in 2D space?
4x4 imagey
x(0,0)x=-0.5 x=3.5
y=-0.5
y=3.5
![Page 9: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/9.jpg)
Raster Image (again)• Ignore the z-coordinates of points for now◦ In practice, we need the z-coordinates and this will be covered later.
• Map the square −1,1 2to the rectangle −0.5,𝑛𝑛𝑥𝑥 − 0.5 × [−0.5,𝑛𝑛𝑦𝑦 − 0.5]
• Where do we need to locate pixels in 2D space?
• The rectangular domain of a 𝑛𝑛𝑥𝑥 × 𝑛𝑛𝑦𝑦 image◦ 𝑅𝑅 = −0.5,𝑛𝑛𝑥𝑥 − 0.5 × [−0.5,𝑛𝑛𝑦𝑦 − 0.5]
![Page 10: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/10.jpg)
Viewport Transformation• Ignore the z-coordinates of points for now◦ In practice, we need the z-coordinates and this will be covered later.
• Map the square −1,1 2to the rectangle −0.5,𝑛𝑛𝑥𝑥 − 0.5 × [−0.5,𝑛𝑛𝑦𝑦 − 0.5]
• Q. How do we transform a rectangle to another rectangle?
![Page 11: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/11.jpg)
Example: Windowing Transform• Problem specification: move a 2D rectangle into a new position
y
x
(𝑥𝑥𝑙𝑙 ,𝑦𝑦𝑙𝑙)
(𝑥𝑥ℎ,𝑦𝑦ℎ) y
x
(𝑥𝑥𝑙𝑙′,𝑦𝑦𝑙𝑙′)
(𝑥𝑥ℎ′ ,𝑦𝑦ℎ′ )
![Page 12: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/12.jpg)
Example: Windowing Transform• Problem specification: move a 2D rectangle into a new position◦ Step1. translate: move the point 𝑥𝑥𝑙𝑙 ,𝑦𝑦𝑙𝑙 to the origin
y
x
(𝑥𝑥𝑙𝑙 ,𝑦𝑦𝑙𝑙)
(𝑥𝑥ℎ,𝑦𝑦ℎ) y
x
(𝑥𝑥ℎ − 𝑥𝑥𝑙𝑙 ,𝑦𝑦ℎ − 𝑦𝑦𝑙𝑙)
![Page 13: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/13.jpg)
Example: Windowing Transform• Problem specification: move a 2D rectangle into a new position◦ Step2. scale: resize the rectangle to be the same size of the target.
y
x
y
x
(𝑥𝑥ℎ − 𝑥𝑥𝑙𝑙 ,𝑦𝑦ℎ − 𝑦𝑦𝑙𝑙)(𝑥𝑥ℎ′ − 𝑥𝑥𝑙𝑙′,𝑦𝑦ℎ′ − 𝑦𝑦𝑙𝑙′)
![Page 14: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/14.jpg)
Example: Windowing Transform• Problem specification: move a 2D rectangle into a new position◦ Step3. translate: move the origin to point (𝑥𝑥𝑙𝑙′,𝑦𝑦𝑙𝑙′)
y
x
y
x
(𝑥𝑥ℎ′ − 𝑥𝑥𝑙𝑙′,𝑦𝑦ℎ′ − 𝑦𝑦𝑙𝑙′)
(𝑥𝑥𝑙𝑙′,𝑦𝑦𝑙𝑙′)
(𝑥𝑥ℎ′ ,𝑦𝑦ℎ′ )
![Page 15: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/15.jpg)
Example: Windowing Transform• Problem specification: move a 2D rectangle into a new position
◦ Target = translate(𝑥𝑥𝑙𝑙′,𝑦𝑦𝑙𝑙′) 𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑠𝑥𝑥ℎ′ −𝑥𝑥𝑙𝑙
′
𝑥𝑥ℎ−𝑥𝑥𝑙𝑙, 𝑦𝑦ℎ
′−𝑦𝑦𝑙𝑙′
𝑦𝑦ℎ−𝑦𝑦𝑙𝑙𝑡𝑡𝑡𝑡𝑠𝑠𝑛𝑛𝑠𝑠𝑠𝑠𝑠𝑠𝑡𝑡𝑠𝑠(−𝑥𝑥𝑙𝑙 ,−𝑦𝑦𝑙𝑙)
◦ =1 0 𝑥𝑥𝑙𝑙′
0 1 𝑦𝑦𝑙𝑙′0 0 1
𝑥𝑥ℎ′ −𝑥𝑥𝑙𝑙
′
𝑥𝑥ℎ−𝑥𝑥𝑙𝑙0 0
0 𝑦𝑦ℎ′−𝑦𝑦𝑙𝑙
′
𝑦𝑦ℎ−𝑦𝑦𝑙𝑙0
0 0 1
1 0 −𝑥𝑥𝑙𝑙0 1 −𝑦𝑦𝑙𝑙0 0 1
◦ =
𝑥𝑥ℎ′ −𝑥𝑥𝑙𝑙
′
𝑥𝑥ℎ−𝑥𝑥𝑙𝑙0 𝑥𝑥𝑙𝑙
′𝑥𝑥ℎ−𝑥𝑥ℎ′ 𝑥𝑥𝑙𝑙
𝑥𝑥ℎ−𝑥𝑥𝑙𝑙
0 𝑦𝑦ℎ′−𝑦𝑦𝑙𝑙
′
𝑦𝑦ℎ−𝑦𝑦𝑙𝑙
𝑦𝑦𝑙𝑙′𝑦𝑦ℎ−𝑦𝑦ℎ
′𝑦𝑦𝑙𝑙𝑦𝑦ℎ−𝑦𝑦𝑙𝑙
0 0 1
![Page 16: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/16.jpg)
Viewport Transformation• Ignore the z-coordinates of points for now◦ In practice, we need the z-coordinates and this will be covered later.
• Map the square −1,1 2to the rectangle −0.5,𝑛𝑛𝑥𝑥 − 0.5 × [−0.5,𝑛𝑛𝑦𝑦 − 0.5]
•𝑥𝑥𝑠𝑠𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑦𝑦𝑠𝑠𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐𝑐
1=
𝑐𝑐𝑥𝑥2
0 𝑐𝑐𝑥𝑥−12
0 𝑐𝑐𝑦𝑦2
𝑐𝑐𝑦𝑦−12
0 0 1
𝑥𝑥𝑐𝑐𝑎𝑎𝑐𝑐𝑎𝑎𝑐𝑐𝑎𝑎𝑐𝑐𝑎𝑎𝑙𝑙𝑦𝑦𝑐𝑐𝑎𝑎𝑐𝑐𝑎𝑎𝑐𝑐𝑎𝑎𝑐𝑐𝑎𝑎𝑙𝑙
1
• For the case with z-coordinates,
◦ 𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣 =
𝑐𝑐𝑥𝑥2
0
0 𝑐𝑐𝑦𝑦2
0 𝑐𝑐𝑥𝑥−12
0 𝑐𝑐𝑦𝑦−12
0 00 0
1 00 1
![Page 17: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/17.jpg)
Sequence of Spaces and Transformations
Object space
Modeling transformation
World space
Viewingtransformation
Eye (camera) space
ProjectionTransformation
Canonical view volume (normalized device coordinates)
ViewportTransformation
Screen space
![Page 18: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/18.jpg)
Projections• Transform 3D points in eye space to 2D points in image
space
• Two types of projections◦ Orthographic projection◦ Perspective projection
Modeling Transformation
Illumination
Viewing Transformation
Clipping
Projection
Rasterization
Display
x
y
z
![Page 19: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/19.jpg)
Orthographic Projection• Assumption◦ A viewer is looking along the minus z-axis with his head pointing in the y-direction
◦ Implies n > f
x
y
z(l,b,n)
(r,t,f)
![Page 20: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/20.jpg)
Orthographic Projection• The view volume (orthographic view volume) is an axis-aligned box ◦ [l, r] x [b, t] x [f, n]
• Notations◦ 𝑥𝑥 = 𝑠𝑠 ≡ 𝑠𝑠𝑠𝑠𝑙𝑙𝑡𝑡 𝑝𝑝𝑠𝑠𝑠𝑠𝑛𝑛𝑠𝑠, 𝑥𝑥 = 𝑡𝑡 ≡ 𝑡𝑡𝑟𝑟𝑟𝑟𝑟𝑡𝑡 𝑝𝑝𝑠𝑠𝑠𝑠𝑛𝑛𝑠𝑠◦ 𝑦𝑦 = 𝑏𝑏 ≡ 𝑏𝑏𝑏𝑏𝑡𝑡𝑡𝑡𝑏𝑏𝑏𝑏 𝑝𝑝𝑠𝑠𝑠𝑠𝑛𝑛𝑠𝑠,𝑦𝑦 = 𝑡𝑡 ≡ 𝑡𝑡𝑏𝑏𝑝𝑝 𝑝𝑝𝑠𝑠𝑠𝑠𝑛𝑛𝑠𝑠◦ 𝑧𝑧 = 𝑛𝑛 ≡ 𝑛𝑛𝑠𝑠𝑠𝑠𝑡𝑡 𝑝𝑝𝑠𝑠𝑠𝑠𝑛𝑛𝑠𝑠, 𝑧𝑧 = 𝑙𝑙 ≡ 𝑙𝑙𝑠𝑠𝑡𝑡 𝑝𝑝𝑠𝑠𝑠𝑠𝑛𝑛𝑠𝑠
x
y
z(l,b,n)
(r,t,f)
![Page 21: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/21.jpg)
Orthographic Projection• Transform points in orthographic view volume to the canonical view volume◦ Also windowing transform (3D)
(l,b,n)
(r,t,f)
(-1,-1,-1)
(1,1,1)
Projectiontransformation
![Page 22: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/22.jpg)
Orthographic Projection• Transform points in orthographic view volume to the canonical view volume◦ Also windowing transform (3D)
◦ Map a box 𝑥𝑥𝑙𝑙 , 𝑥𝑥ℎ × 𝑦𝑦𝑙𝑙 ,𝑦𝑦ℎ × 𝑧𝑧𝑙𝑙 , 𝑧𝑧ℎ to another box 𝑥𝑥𝑙𝑙′, 𝑥𝑥ℎ′ × 𝑦𝑦𝑙𝑙′, 𝑦𝑦ℎ′ × [𝑧𝑧𝑙𝑙′, 𝑧𝑧ℎ′ ]
◦
𝑥𝑥ℎ′ −𝑥𝑥𝑙𝑙
′
𝑥𝑥ℎ−𝑥𝑥𝑙𝑙0
0 𝑦𝑦ℎ′−𝑦𝑦𝑙𝑙
′
𝑦𝑦ℎ−𝑦𝑦𝑙𝑙
0 𝑥𝑥𝑙𝑙′𝑥𝑥ℎ−𝑥𝑥ℎ
′ 𝑥𝑥𝑙𝑙𝑥𝑥ℎ−𝑥𝑥𝑙𝑙
0 𝑦𝑦𝑙𝑙′𝑦𝑦ℎ−𝑦𝑦ℎ
′ 𝑦𝑦𝑙𝑙𝑦𝑦ℎ−𝑦𝑦𝑙𝑙
0 00 0
𝑧𝑧ℎ′−𝑧𝑧𝑙𝑙′𝑧𝑧ℎ−𝑧𝑧𝑙𝑙
𝑧𝑧𝑙𝑙′𝑧𝑧ℎ−𝑧𝑧ℎ
′ 𝑧𝑧𝑙𝑙𝑧𝑧ℎ−𝑧𝑧𝑙𝑙
0 1
![Page 23: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/23.jpg)
Orthographic Projection• Transform points in orthographic view volume to the canonical view volume◦ Also windowing transform (3D)
• 𝑀𝑀𝑎𝑎𝑐𝑐𝑣𝑣ℎ𝑎𝑎 =
2𝑐𝑐−𝑙𝑙
0
0 2𝑣𝑣−𝑏𝑏
0 −𝑐𝑐+𝑙𝑙𝑐𝑐−𝑙𝑙
0 − 𝑣𝑣+𝑏𝑏𝑣𝑣−𝑏𝑏
0 00 0
2𝑐𝑐−𝑓𝑓
− 𝑐𝑐+𝑓𝑓𝑐𝑐−𝑓𝑓
0 1
![Page 24: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/24.jpg)
Composite Transformation• The matrix that transforms points in world space to screen coordinate:
• 𝑀𝑀 = 𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑀𝑀𝑎𝑎𝑐𝑐𝑣𝑣ℎ𝑎𝑎𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣
![Page 25: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/25.jpg)
Orthographic Projection• Transform points in orthographic view volume to the canonical view volume◦ Also windowing transform (3D)
• Tend to ignore relative distances between objects and eye◦ Unrealistic
• In practice, ◦ We usually do not use this projection.◦ It can be useful in applications where relative lengths should be judged.
![Page 26: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/26.jpg)
Orthographic Projection in OpenGL• void glOrtho(GLdouble left, GLdouble right,
• GLdouble bottom, GLdouble top,
• GLdouble nearVal, GLdouble farVal);
(l,b,n)
(r,t,f)
![Page 27: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/27.jpg)
Perspective Projection• Objects in an image become smaller as their distance from the eye increases.
• History of perspective:◦ Artists from the Renaissance period employed the perspective property.
Images from wikipedia
![Page 28: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/28.jpg)
Perspective Projection• Objects in an image become smaller as their distance from the eye increases.
• History of perspective:◦ Artists from the Renaissance period employed the perspective property.
• In everyday life?
![Page 29: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/29.jpg)
Perspective Projection• 𝑦𝑦𝑠𝑠 = 𝑑𝑑
𝑧𝑧𝑦𝑦
◦ 𝑦𝑦𝑠𝑠: y-axis coordinate in view plane◦ y: distance of the point along the y-axis
d
view
pla
ne
e g
z
𝑦𝑦
𝑦𝑦𝑠𝑠
![Page 30: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/30.jpg)
Homogeneous Coordinate• Represent a point 𝑥𝑥, 𝑦𝑦, 𝑧𝑧 with an extra coordinate w◦ 𝑥𝑥,𝑦𝑦, 𝑧𝑧,𝑤𝑤◦ In the previous lecture, 𝑤𝑤 = 1
• Let’s define 𝑤𝑤 to be the denominator of the x-, y-, z-coordinates◦ (𝑥𝑥, 𝑦𝑦, 𝑧𝑧,𝑤𝑤) represent the 3D point (𝑥𝑥
𝑣𝑣, 𝑦𝑦𝑣𝑣
, 𝑧𝑧𝑣𝑣
)◦ A special case, 𝑤𝑤 = 1, is still valid.◦ 𝑤𝑤 can be any values
![Page 31: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/31.jpg)
Projective Transform• Let’s define 𝑤𝑤 to be the denominator of the x-, y-, z-coordinates◦ (𝑥𝑥, 𝑦𝑦, 𝑧𝑧,𝑤𝑤) represent the 3D point (𝑥𝑥
𝑣𝑣, 𝑦𝑦𝑣𝑣
, 𝑧𝑧𝑣𝑣
)◦ A special case, 𝑤𝑤 = 1, is still valid.◦ 𝑤𝑤 can be any values
• Projective transformation
◦
�𝑥𝑥�𝑦𝑦�̃�𝑧�𝑤𝑤
=
𝑠𝑠1 𝑏𝑏1𝑠𝑠2 𝑏𝑏2
𝑠𝑠1 𝑑𝑑1𝑠𝑠2 𝑑𝑑2
𝑠𝑠3 𝑏𝑏3𝑠𝑠 𝑙𝑙
𝑠𝑠3 𝑑𝑑3𝑟𝑟 𝑟
𝑥𝑥𝑦𝑦𝑧𝑧1
◦ 𝑥𝑥′,𝑦𝑦′, 𝑧𝑧′ = ( �𝑥𝑥�𝑣𝑣
, �𝑦𝑦�𝑣𝑣, �𝑧𝑧�𝑣𝑣
)
![Page 32: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/32.jpg)
Perspective Projection• Example with 2D homogeneous vector 𝑦𝑦 𝑧𝑧 1 𝑇𝑇
◦𝑦𝑦𝑠𝑠1 = 𝑑𝑑 0 0
0 1 0
𝑦𝑦𝑧𝑧1
◦ This is corresponding to the perspective equation, 𝑦𝑦𝑠𝑠 = 𝑑𝑑𝑧𝑧𝑦𝑦.
![Page 33: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/33.jpg)
Perspective Projection• Some info. for perspective matrix◦ Define our project plane as the near plane◦ Distance to the near plane: −𝑛𝑛◦ Distance to the far plane: −𝑙𝑙
• Perspective equation: 𝑦𝑦𝑠𝑠 = 𝑐𝑐𝑧𝑧𝑦𝑦
• Perspective matrix
◦ 𝑃𝑃 =𝑛𝑛 00 𝑛𝑛
0 00 0
0 00 0
𝑛𝑛 + 𝑙𝑙 −𝑙𝑙𝑛𝑛1 0
![Page 34: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/34.jpg)
Perspective Projection• Perspective matrix
◦ 𝑃𝑃 =𝑛𝑛 00 𝑛𝑛
0 00 0
0 00 0
𝑛𝑛 + 𝑙𝑙 −𝑙𝑙𝑛𝑛1 0
• A mapping with the perspective matrix:
◦ 𝑃𝑃
𝑥𝑥𝑦𝑦𝑧𝑧1
=
𝑛𝑛𝑥𝑥𝑛𝑛𝑦𝑦
𝑛𝑛 + 𝑙𝑙 𝑧𝑧 − 𝑙𝑙𝑛𝑛𝑧𝑧
=
𝑐𝑐𝑥𝑥𝑧𝑧𝑐𝑐𝑦𝑦𝑧𝑧
𝑛𝑛 + 𝑙𝑙 − 𝑓𝑓𝑐𝑐𝑧𝑧
1
![Page 35: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/35.jpg)
Perspective Projection• A mapping with the perspective matrix:
◦ 𝑃𝑃
𝑥𝑥𝑦𝑦𝑧𝑧1
=
𝑛𝑛𝑥𝑥𝑛𝑛𝑦𝑦
𝑛𝑛 + 𝑙𝑙 𝑧𝑧 − 𝑙𝑙𝑛𝑛𝑧𝑧
=
𝑐𝑐𝑥𝑥𝑧𝑧𝑐𝑐𝑦𝑦𝑧𝑧
𝑛𝑛 + 𝑙𝑙 − 𝑓𝑓𝑐𝑐𝑧𝑧
1• Properties◦ The first, second, and fourth rows are for the perspective equation.◦ The third row is for keeping z coordinate at least approximately.
◦ E.g., when z = n, transformed z coordinate is still n.◦ E.g., when 𝑧𝑧 > 𝑛𝑛, we cannot preserve the z coordinate exactly, but relative orders between points will be
preserved.
![Page 36: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/36.jpg)
Perspective Projection• Perspective matrix◦ Map the perspective view volume to the orthographic view volume.
![Page 37: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/37.jpg)
Composite Transformation• The matrix that transforms points in world space to screen coordinate:
• 𝑀𝑀 = 𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑀𝑀𝑎𝑎𝑐𝑐𝑣𝑣ℎ𝑎𝑎𝑃𝑃𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣 = 𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑀𝑀𝑣𝑣𝑐𝑐𝑐𝑐𝑀𝑀𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣𝑎𝑎𝑐𝑐𝑣𝑣
• 𝑀𝑀𝑣𝑣𝑐𝑐𝑐𝑐 = 𝑀𝑀𝑎𝑎𝑐𝑐𝑣𝑣ℎ𝑎𝑎𝑃𝑃 (perspective projection matrix)
◦ 𝑀𝑀𝑣𝑣𝑐𝑐𝑐𝑐 =
2𝑐𝑐𝑐𝑐−𝑙𝑙
0
0 2𝑐𝑐𝑣𝑣−𝑏𝑏
𝑙𝑙+𝑐𝑐𝑙𝑙−𝑐𝑐
0𝑏𝑏+𝑣𝑣𝑏𝑏−𝑣𝑣
0
0 00 0
𝑓𝑓+𝑐𝑐𝑐𝑐−𝑓𝑓
2𝑓𝑓𝑐𝑐𝑓𝑓−𝑐𝑐
1 0
![Page 38: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/38.jpg)
Perspective Projection in OpenGL• void glFrustum(GLdouble left, GLdouble right,
• GLdouble bottom, GLdouble top,
• GLdouble nearVal, GLdouble farVal);
![Page 39: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/39.jpg)
Perspective Projection in OpenGL• void gluPerspective(GLdouble fovy, GLdouble aspect,
• GLdouble zNear, GLdouble zFar);
• Parameters ◦ fovy: field of view (in degrees) in the y direction◦ aspect: aspect ratio is the ratio of x (width) to y (height)
• Symmetric constraints are implicitly applied.◦ l = -r, b = -t
• A constraint to prevent image distortion◦ 𝑐𝑐𝑥𝑥𝑐𝑐𝑦𝑦
= 𝑐𝑐𝑣𝑣 x
y
z
𝜃𝜃2
![Page 40: CT4510: Computer Graphics Projections › courses › 2018_spring_CG › 2018_03... · 2020-03-11 · Clipping. Projection. Rasterization. Display. Sequence of Spaces and Transformations](https://reader033.vdocument.in/reader033/viewer/2022042316/5f0455827e708231d40d76fb/html5/thumbnails/40.jpg)
Further Reading• In our textbook, Fundamentals of Computer Graphics (4th edition)◦ Chapter 7