480 likes | 666 Views
第六章 視景圖形座標轉換. World → Device Transformation. Viewport. World. Device. Windows. WCS (World Coordinate System). PDCS (Physical Device Coordinate System). NDCS (Normalized Coordinate System). UCS (User Coordinate System). WCS:theoretically infinite.
E N D
第六章 視景圖形座標轉換 World → Device Transformation Viewport World Device
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
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
Viewport Window Normalized Device Coordinate (parameter 0~1) Workstation Coordinate World Coordinate
Window – to – Viewport Transformation Window Viewport World Normalization Device
Point in Window in a viewport and
Window – to – Viewport Transformation Scaling Maintain relative proportion ( 保持比例 ) Window size = Viewport size 如果 ( 大小不變 ) 不變 放大 縮小 Translation 平移
Boundary Conflicts(衝突) 處理方法 1. Wraparound(捲折) 轉折至下方繼續 2. Scissoring(切斷) 在Hardware 上切斷
Boundary Conflicts(cont.) 處理方法 3. Saturation(滲透) 以 為基準 向下擠 4. Clipping(修剪) 以 為基準 切斷
CLIPPING 幾何計算 1. Analytical World 畫素計算 2. Raster World Point Clipping A point is inside the window Visible
Point Clipping (cont.) Both True Inside the Window
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
Line Clipping 修剪 Cohen – Sutherland Algorithm 將 Clip rectangle 分為 9 份 將 4-bit code assign 給每一點 (四個邊) Each end point 一條線的2端點, 每一端點給一個Code 0 0 0 0 4 3 2 bit 1 從右至左,視Window 之關係位置給予Code
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
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
Logical AND of both codes of end points Line End point bit codes Logic AND Conclusion 1 2 3 4 5 0000 0000 0100 0100 1000 0010 0000 0010 0001 0100 Completely Visible Completely Invisible No Conclusion Partially Visible No Conclusion 0000 0 0100 1 0000 0 0000 0 0000 0 Completely Visible Completely Invisible 判 斷 準 則 Partially Visible No Conclusion
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 Partially Partially Completely Invisible 1000 0000 0000 0000 0001 6 7 8 9 10 1001 1000 1000 0000 1001 0000 1001 0000 1001 0001
Partially Visible or No Conclusion (求線與Clipping Windows之交點) 1. Find Intersection Points Line 2. In , Out Intersection Points (1) Left (2) Right
(3) Bottom (4) Top 防止延伸線上的交點 3. Check Parametric Equations Line Each Intersection Point 4 Boundary Line (1) Line(線)
(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
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 (邊線法向量)
Cyrus – Beck Technique (cont.) 在 Edge Ei上任取一點 P Ei 取 3 個向量:(1)PEi to P0 (2)PEi在 Edge Ei上 (3)PEi to P1
Cyrus – Beck Technique (cont.) 根據 判斷 在外面 在Edge上 在內部 (Counterclockwise Edge Index) Intersection Point: with Edge Ei 公式推導如下頁
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)
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 )
Clipping Polygons 2 Polygons Clipping Each Line before after
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
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
Saved Vertices New Polygon 2 3 1‘ 2‘ 1‘ 2‘ 4 1 3‘ 3‘ 5‘ 4‘ 5‘ 4‘ 6 5
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內的物體才會被投影及顯示
View Volume (cont.) Parallel Projection Perspective Projection Truncated Pyramid Frustum 截斷角錐幾何體
Parallel Projection near:hither 此處 far:yon plane 彼處 near:front far:back
Perspective Projection Center of Projection
3 - D Viewport is a regular parallelepiped(平行六面體) defined innormalized coordinates 3 - D Window - to – viewport mapping 比例 位移
3 - D Window - to - viewport mapping (cont.) y z x View Volume 3 - D viewport
3 - D Window - to - viewport mapping (cont.) View Volume:defined by and 3 - D viewport :defined by and
Clipping against a normalized View Volume Extension of Code of 6 bits right to left(六個面) 000000 back front above below right left 後 前 上 下 右 左 Bit 6 Bit 1
Code of 6 bits right to left (cont.) bit 1 left bit 2 right bit 3 below bit 4 above bit 5 front bit 6 back Code Code Logical AND of 2 codes 2 end points of a line
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
Code of 6 bits right to left (cont.) Line 其中 1.Intersection of a line with a ( face plane ) of view volume 2. with front
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(超出邊界)
Side View P2 A P1 P2 B P1 3. Check Intersection with 6 ( faces ) planes