two-dimensional viewing
DESCRIPTION
Two-Dimensional Viewing. 6. Contents. Window and Viewport The Viewing Transformation Window-to-Viewport coordinate transformation Point clipping Line clipping Polygon clipping Exterior clipping. Window and Viewport. Window A world-coordinate area selected for display - PowerPoint PPT PresentationTRANSCRIPT
Two-Dimensional Viewing66
2D Viewing
Contents
Window and Viewport The Viewing Transformation Window-to-Viewport coordinate transformation Point clipping Line clipping Polygon clipping Exterior clipping
2D Viewing
Window and Viewport Window
A world-coordinate area selected for display What is to be viewed
Viewport An area on a display device to which a window is mapp
ed Where is to be displayed
World Coordinates Device Coordinates
2D Viewing
Window and Viewport ( 계속 )
Window to Viewport Mapping
2D Viewing
Window and Viewport ( 계속 )
2D Viewing
The Viewing Transformation
Viewing transformation window-to-viewport transformation, windowing transformatio
n
Normalized Device Coordinates
construct world coordinates
convert to viewing coordinates
map to normalized viewing coordinates
map to device coordinates
World Coordinatesviewport clipping
2D Viewing
Viewing coordinatereference frame
World 좌표 View 좌표 1. 중심 이동 2. 회전 MWC,VC = R• T
뷰좌표 중심을 전체좌표 중심으로
이동
두 좌축의 축을 맞추는회전
2D Viewing
Window-to-ViewportCoordinate Transformation
윈도우의 점을 뷰포트로 변경 상대 거리를 유지하게 함
minmax
min
minmax
min
minmax
min
minmax
min
ywyw
ywyw
yvyv
yvyv
xwxw
xwxw
xvxv
xvxv
Window to ViewportTransformation
minmax
minmax
minmax
minmax
ywyw
yvyvsy
xwxw
xvxvsx
syywywyvyv
sxxwxwxvxv
)(
)(
minmin
minmin
,
1. Scaling the window to the size of the viewport2. Translate to the position of the viewport
2D Viewing
Workstation transformation Normalized coordinates 에서 다양한 device 로 매핑 각 device 마다 window-to-viewport transformation
수행 하나의 뷰의 다른 부분을 각 장치에서 볼 수 있음
2D Viewing
Clipping
Clipping 그림의 일부가 정해진 영역 내부인지 외부인지 구별 전체좌표계에 적용
Point clipping 다음을 만족하는 점 P=(x,y) 저장
응용 : 폭발 , 바다등 particle model 의 화면처리
maxmin
maxmin
ywyyw
xwxxw
2D Viewing
Line Clipping
Before Clipping After Clipping
1. Check all segments Intersect the window boundary
2. Clip line segments Calculate the intersections with the window boundary
1u0,-yy u yy
-xx u xx
121
121
)(
)(
2D Viewing
Cohen-Sutherland Line Clipping
Basic idea
Encode the line endpointsSuccessively divide the line segments so that they are
completely contained in the window or completely lies out side window
Division occurs at the boundary of window
2D Viewing
Cohen-Sutherland Line Clipping
2 진 영역 코드 (region code)– 4bits : 왼쪽 , 오른쪽 , 아래 , 위
– clipping 사각형에 대한 위치 의미
– 0000 : clipping 사각형 내의 점
선의 구분– Visible : 선의 양 끝점의 code 가 모두 0000
– Invisible : 양 끝점 code 의 Logical AND 가 0000 이 아닐 때
– Indeterminate : Logical AND 는 0000 이지만 , 끝점의 code가 0000 이 아닌 경우 이 경우에 대해 Clipping 실시
선 끝점에 대한 2 진 영역코드
A
B
2D Viewing
Cohen-Sutherland Line Clipping
경계와의 교차점 찾기
( 예 )– P1 에서 P2 로 지나는 선분
아래 끝점 P1 의 좌 , 우 , 하방에 대한 경계비교 창의 아래쪽이므로 창 아래 경계 교차점 P1’ 찾음 P1 에서 P1’ 버림 상단 : P2 --> P2‘--> P2“ 순으로 찾아 나감
– P3 에서 P4 로 지나는 선분 P3 는 창 왼쪽이므로 P3’ 찾아 선분 P3 에서 P3’ 은 버림 선분 P3’ 에서 P4 는 창 아래이므로 버림
절단 창을 지나는 두 선분
P1
P2
P3
P’2 P”2
P4P’3
P’1m
yyxx 1
1
)( 11 xxmyy
2D Viewing
Cohen-Sutherland Line Clipping
Quiz)
(2,2)
(8,8)A
B
C
D
Line AB : A(3,10), B(6,12) CD : C(4,1), D(10,6)
2,2 BL yx
8,8 TR yx
2D Viewing
Cohen-Sutherland Line Clipping
(2,2)
(8,8)A
B
C
D
Step1. Encode end points
Step2. Clip line CD
AB A(3,10) 1000 B(6,12) 1000
Logical AND 1000
CD C( 4, 1) 0100 D(10,6) 0010
Logical AND 0000Invisible Indeterminate
uuy
uux
51)16(1
64)410(4
:'C
:'D)2,2.5('
2.55/1
)0100:(2
C
xu
Cyy B
)33.4,8('
33.43/2
)0010:(8
D
yu
Dxx R
'C
'D
2D Viewing
Midpoint Subdivision
Similar to Cohen-Sutherland Algorithm except dividing strategy
Division occurres at midpoints!!
Pm
Pm
Pm
Window
2D Viewing
Midpoint Subdivision
Ex) Window : (2,2),(8,6)Line AB : A(4,3), B(10,5)
A 0000 B 0010
Logical AND 0000Indeterminate
SubDivisions
MidPoints
SegmentFurther
ChosenDivision
1 (7,4) (7,4) ~ (10,5)234..
2D Viewing
Polygon Clipping
Line clipper 이용 , 몇 개의 닫힌 다각형들 생성
Window boundary 를 따라가며 Clipping 수행
Before Clipping After Clipping
2D Viewing
Polygon Clipping (계속 )
Sutherland-Hodgeman Clipping 다각형 정점 처리방법 - 시계방향으로 edge 탐색
처리된 정점을 다음 면에 반복 적용
Concave polygon 에는 부적합
(a) (b) (c) (d)
2D Viewing
Polygon Clipping (계속 )
Weiler-Atherton Polygon Clipping Concave Polygon 에도 적용가능 하도록
Clipping 에 Polygon edge 뿐 아니라 Window boundary 도 사용
탐색원리 ( 시계 방향의 경우 )
– 바깥쪽 안쪽 : 다각형의 경계 따름
– 안쪽 바깥쪽 : 창의 경계 따라 탐색
응용 : Weiler Polygon Clipping 임의의 다각형의 경계 처리
Weiler polygon clipping
Weiler-atherton polygon clipping을 적용하여 두개 영역 생성
2D Viewing
Exterior Clipping
Exterior Clipping 영역의 바깥쪽을 저장 적용 예
– Multiple window system– 그림에 라벨이나 디자인 패턴 입력– 안쪽 절단에 응용
Interior clipping 과 exterior clipping 을 이용한polygon 내부 line clipping