Download presentation
Presentation is loading. Please wait.
1
World → Device Transformation
第六章 視景圖形座標轉換 World → Device Transformation Viewport World Device
2
Windows WCS (World Coordinate System)
PDCS (Physical Device Coordinate System) NDCS (Normalized Coordinate System) UCS (User Coordinate System) WCS:theoretically infinite Window:a finite region in WCS Viewport:defines the physical location of the display area within the physical raster
3
Normalization Transformation (N):
World Coordinate Normalized Device Coordinates map Workstation Transformation (W): Normalized Device Coordinate Physical Device Coordinate map Viewing Transformation (V): V = W‧N
4
Coordinate (parameter 0~1)
Viewport Window Normalized Device Coordinate (parameter 0~1) Workstation Coordinate World Coordinate
5
Window – to – Viewport Transformation
World Normalization Device
6
Mapped to viewport area
7
Point in Window in a viewport and
8
Window – to – Viewport Transformation
Scaling Maintain relative proportion ( 保持比例 ) Window size = Viewport size 如果 ( 大小不變 ) 不變 放大 縮小 Translation 平移
9
Boundary Conflicts(衝突)
處理方法 1. Wraparound(捲折) 轉折至下方繼續 2. Scissoring(切斷) 在Hardware 上切斷
10
Boundary Conflicts(cont.)
處理方法 3. Saturation(滲透) 以 為基準 向下擠 4. Clipping(修剪) 以 為基準 切斷
11
CLIPPING Point Clipping
幾何計算 1. Analytical World 畫素計算 2. Raster World Point Clipping A point is inside the window Visible
12
Point Clipping (cont.) Both True Inside the Window
13
Clipping lines Analytical Clipping Check In or Out of 2 end points
Both In Both Out One In / One Out Need to Check Parametric Equation Need to Calculate Intersection points
14
Cohen – Sutherland Algorithm
Line Clipping 修剪 Cohen – Sutherland Algorithm 將 Clip rectangle 分為 9 份 將 4-bit code assign 給每一點 (四個邊) Each end point 一條線的2端點, 每一端點給一個Code bit 1 從右至左,視Window 之關係位置給予Code
15
Cohen – Sutherland Algorithm (cont.)
bit 1:left bit 2:right bit 3:below bit 4:above 1001 1000 1010 0001 0000 Window 0010 0101 0100 0110
16
Cohen – Sutherland Algorithm (cont.)
bit 1:sign bit of bit 2:sign bit of bit 3:sign bit of bit 4:sign bit of 6 8 1001 1000 3 1010 9 7 10 1 0000 0001 0010 5 4 2 0101 0110 0100
17
Logical AND of both codes of end points
Line End point bit codes Logic AND Conclusion 1 2 3 4 5 Completely Visible Completely Invisible No Conclusion Partially Visible Completely Visible Completely Invisible 判 斷 準 則 Partially Visible No Conclusion
18
Logical AND of both codes of end points (cont.)
Need to check intersection points Line Codes of 2 end points AND Conclusion Completely Invisible Partially 1000 0000 0001 6 7 8 9 10
19
Partially Visible or No Conclusion (求線與Clipping Windows之交點)
1. Find Intersection Points Line In , Out Intersection Points (1) Left (2) Right
20
3. Check Parametric Equations
(3) Bottom (4) Top 防止延伸線上的交點 3. Check Parametric Equations Line Each Intersection Point 4 Boundary Line (1) Line(線)
21
If 2 intersection points
(2) Boundary (邊界) (3) If (1)、(2)、(3)皆成立 Intersection True If 2 intersection points New Line If 1 intersection point check ( code 0000 ) the point in window for example ( code 0000 ) and 定義 New Line
22
Cyrus – Beck Technique Algorithm: Clipping a 2-D line against a
rectangle or a convex凸 polygon Edge Ei PEi P1 P0 Ni Normal of Edge Ei (邊線法向量)
23
Cyrus – Beck Technique (cont.)
在 Edge Ei 上任取一點 P Ei 取 3 個向量:(1)PEi to P0 (2)PEi 在 Edge Ei 上 (3)PEi to P1
24
Cyrus – Beck Technique (cont.)
根據 判斷 在外面 在Edge上 在內部 (Counterclockwise Edge Index) Intersection Point: with Edge Ei 公式推導如下頁
25
Cyrus – Beck Technique (cont.)
代入 and
26
Cyrus – Beck Technique (cont.)
Line 1 P1 Line 3 PE P1 Line 2 PL P1 PL PL P0 PE P0 PL PE PE P0 交點分類:PE(Potentially Energy) PL(Potentially Leaving)
27
Cyrus – Beck Technique (cont.)
PE PL Choose a ( PE , PL ) pair PE:with tE PL:with tL The intersecting line segment is defined by ( tE , tL )
28
Calculations for Parametric Line Clipping
Clip Edge Ei Normal Ni PEi P0-PEi Left Right Bottom Top
29
Calculations for Parametric Line Clipping
30
2 Polygons Clipping Each Line
Clipping Polygons 2 Polygons Clipping Each Line before after
31
Sutherland – Hodgman Algorithm
Polygon:a set of ordered vertices Compare a polygon to each boundary Output is a set of vertices defining polygon 依序比較 2 polygons 利用切斷各邊 Original Clip Left Clip Right Clip Bottom Clip Top
32
Polygon – Polygon Clipping
Sutherland – Hodgman Algorithm Polygon clockwise Traverse vertices clockwise S:前一點 P:目前點 S P P S I I P P S S IN→IN Save P IN→OUT Save I OUT→OUT No Save OUT→IN Save I , P
33
Saved Vertices New Polygon 2 3 1‘ 2‘ 1‘ 2‘ 4 1 3‘ 3‘ 5‘ 4‘ 5‘ 4‘ 6 5
34
View Volume In 3 – D viewing:
Projection(投影) Window is used to define a View Volume. View plane is z = 0 plane Window is defined by on the view plane Only those objects within the view volume are projected and displayed on the view plane. 只有在view volume內的物體才會被投影及顯示
35
View Volume (cont.) Parallel Projection Perspective Projection
Truncated Pyramid Frustum 截斷角錐幾何體
36
View Volume (cont.)
37
Parallel Projection near:hither 此處 far:yon plane 彼處 near:front
far:back
38
Perspective Projection
Center of Projection
39
3 - D Window - to – viewport mapping
Viewport is a regular parallelepiped(平行六面體) defined innormalized coordinates 3 - D Window - to – viewport mapping 比例 位移
40
3 - D Window - to - viewport mapping (cont.)
y z x View Volume 3 - D viewport
41
3 - D Window - to - viewport mapping (cont.)
View Volume:defined by and 3 - D viewport :defined by and
42
Clipping against a normalized View Volume
Extension of Code of 6 bits right to left(六個面) back front above below right left 後 前 上 下 右 左 Bit 6 Bit 1
43
Code of 6 bits right to left (cont.)
below bit 4 above bit 5 front bit 6 back Code Code Logical AND of 2 codes 2 end points of a line
44
Code of 6 bits right to left (cont.)
判斷結果 AND = 0,兩端皆 0 Inside AND = 1,兩端有 1 Outside AND = 0,兩端有 1 , 0 Partially Inside AND = 0,兩端都有 1 No Conclusion Check Intersection Points 6 Intersection Points
45
Code of 6 bits right to left (cont.)
Line 其中 1. Intersection of a line with a ( face plane ) of view volume 2. with front
46
Line segment does not intersect
2. with front not in (0 ~ 1) (1) If Line segment does not intersect (2) If in (0 ~ 1) (3) If neither nor is in beyond boundary(超出邊界)
47
3. Check Intersection with 6 ( faces ) planes
Side View P2 A P1 P2 B P1 3. Check Intersection with 6 ( faces ) planes
48
Cyrus - Beck Algorithm 用在 3 - D
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.