Computer Graphics ApplicationsComputer Graphics Applications -...
Transcript of Computer Graphics ApplicationsComputer Graphics Applications -...
Computer Graphics ApplicationsComputer Graphics Applications- Billiards -
14th Week, 2008
Sun-Jeong Kim
DownloadingDownloading
Computer Graphics Applications2
New ProjectNew Project
Computer Graphics Applications3
Result – New ProjectResult New Project
Computer Graphics Applications4
Exercises (1)Exercises (1)
가로:세로 = 2:1 비율인 사각형을 생성하시오가로:세로 = 2:1 비율인 사각형을 생성하시오.
Computer Graphics Applications5
Exercises (2)Exercises (2)
glutSolidCube( )함수를 이용해 경계를 만드시오glutSolidCube( )함수를 이용해 경계를 만드시오.
Computer Graphics Applications6
Exercises (3)Exercises (3)
glutSolidSphere( )함수를 이용해 공을 만드시오glutSolidSphere( )함수를 이용해 공을 만드시오.
Computer Graphics Applications7
Billiard TableBilliard Table
Computer Graphics Applications8
Balls (1)Balls (1)
Computer Graphics Applications9
Balls (2)Balls (2)
Computer Graphics Applications10
Exercises (4)Exercises (4)
공을 (1 0f 1 0f 0 0f) 방향의 등속도 운동 시키시공을 (1.0f, 1.0f, 0.0f) 방향의 등속도 운동 시키시오.
Computer Graphics Applications11
Uniform MotionUniform Motion
V(t) = VV(t) = V0
X(t) = X0 + V(t)t
= X0 + V0t
V
CC' CC
tVCC +=′
tvxx xcc ⋅+=′( )( )
cc
yx
yx ,
=′=
C
C
Computer Graphics Applications12
tvyy ycc ⋅+=′( )( )yx
cc
vv
yx
,
,
== ′′
V
C
Exercises (5)Exercises (5)
경계에 충돌하는 경우 멈추도록 만드시오경계에 충돌하는 경우 멈추도록 만드시오.
Computer Graphics Applications13
Collision Detection – Billiard TableCollision Detection Billiard Table
Outside of (x y ) ~ (x y )Outside of (xmin, ymin) (xmax, ymax)
Radius of a ballWidth of
the border
ad us o a ba
(x y )Height ofthe table
(xmax, ymax)
(xmin, ymin)
Width of the table
Computer Graphics Applications14
Exercises (6)Exercises (6)
충돌 후 입사각과 반사각이 같은 방향으로 속도충돌 후, 입사각과 반사각이 같은 방향으로 속도변경
Computer Graphics Applications15
Collision Response – Billiard TableCollision Response Billiard Table
A' C'B B'
A CDD'
Computer Graphics Applications16
Collision Detection (1)Collision Detection (1)
Computer Graphics Applications17
Collision Detection (2)Collision Detection (2)
Computer Graphics Applications18
Collision Detection (3)Collision Detection (3)
Computer Graphics Applications19
Exercises (7)Exercises (7)
다른 공과 충돌하는 경우 멈추도록 만드시오다른 공과 충돌하는 경우 멈추도록 만드시오.
Computer Graphics Applications20
Collision Detection – BallsCollision Detection Balls
The distance between two centers of the balls ≤The distance between two centers of the balls ≤the addition of two radii of the balls
C C
r1 r0
di
( )( )
000 , yx=C
CC1 C0dist ( )111 , yx=C
( ) ( )22di t +r1 r0
( ) ( )1010 yyxxdist −+−=
( )22di ≤C1 C0( )210
2 rrdist +≤
Computer Graphics Applications21
Exercises (8)Exercises (8)
공과 충돌 후 반응을 구현하시오 (단 회전 운동공과 충돌 후 반응을 구현하시오. (단, 회전 운동제외)
Computer Graphics Applications22
Collision Response – Static Ball(without Spinning)
RvP
VC1
V
C0C'0vh RRV +=
RhCC
CCC
′−′−
=01
01
( )CCVR ⋅=h
hv RVR −=
Computer Graphics Applications23
hv
Exercises (9)Exercises (9)
공을 가속도 운동시켜 일정 시간 후 멈추도록 만공을 가속도 운동시켜, 일정 시간 후 멈추도록 만드시오.
Computer Graphics Applications24
Accelerated MotionAccelerated Motion
V(t) = V + atV(t) = V0 + at
X(t) = X0 + V(t)t21
= X0 + V0t + a t21−2
V(t)
CC'
20 2
1tt aVCC ++=′
210 2
2
2
12
1tatvxx xxcc +⋅+=′( )
( )yx vv ,0 =V( )
( )cc yx
′= ,
C
C
Computer Graphics Applications25
2
2tatvyy yycc +⋅+=′( )yx aa ,=a( )cc yx ′′=′ ,C
Translational Motion (1)Translational Motion (1)
Computer Graphics Applications26
Translational Motion (2)Translational Motion (2)
Computer Graphics Applications27
Translational Motion (3)Translational Motion (3)
Computer Graphics Applications28
Translational Motion (4)Translational Motion (4)
Computer Graphics Applications29
Exercises (10)Exercises (10)
공이 회전하면서 이동하도록 만드시오공이 회전하면서 이동하도록 만드시오.
Computer Graphics Applications30
Rotational Motion (1)Rotational Motion (1)
공을 회전시키면서 이동하도록 만드시오공을 회전시키면서 이동하도록 만드시오.Angular velocity f
dt
d πθω 2==
Frequency (rate of rotation): f
Angular acceleration dωα
( )θ,rP
θr
g
Tangential velocity
dtα =
rv ω=
θ
Tangential velocity
TorqueForce: F
rvr ωατ IFr ==
Moment of inertia: I
Computer Graphics Applications31
Rotational Motion (2)Rotational Motion (2)
| C'−C | = rθ| C −C | = rθRotation axis = ( 0, 0, 1 ) × V(t)
V(t)
CC' CC'
( ) ( )r
yyxx cccc2
'2
' −+−=∴θ( )
( )yx
yx cc ,
′=
C
Cr( )
( ) ( )zyxt
yx
vv
cc
,,
,
== ′′
V
C( ) )0,,()0,,(1,0,0 xyyx vvvv −=×∴
Computer Graphics Applications32
Rotational Motion (3)Rotational Motion (3)
Computer Graphics Applications33
Rotational Motion (4)Rotational Motion (4)
Copy from MyTrackBall::End( ) function
Computer Graphics Applications34
Rotational Motion (5)Rotational Motion (5)
Copy from MyTrackBall::End( ) function
Computer Graphics Applications35
Rotational Motion (6)Rotational Motion (6)
Computer Graphics Applications36
Rotational Motion (7)Rotational Motion (7)
Computer Graphics Applications37
Rotational Motion (8)Rotational Motion (8)
Computer Graphics Applications38
Rotational Motion (9)Rotational Motion (9)
Computer Graphics Applications39
Exercises (11)Exercises (11)
공이 멈춘 후 “Enter” 키를 누르면 반대 쪽 공이공이 멈춘 후, Enter 키를 누르면, 반대 쪽 공이움직이도록 하시오.
Enter: 번갈아 운동 하도록 순서 돌리기Enter: 번갈아 운동 하도록 순서 돌리기
default 속도벡터: 상대방 공을 향하는 단위 벡터
좌 우 화살표: 방향을 좌 우로 이동좌,우 화살표: 방향을 좌, 우로 이동
상, 하 화살표: 속도 벡터의 크기(길이) 조절
기타기타
정확한 충돌체크, 충돌 후 반응계산
최 화코드의 최적화, 주석(설명)
1212월월 44일일 ((목목) ) 수업시간수업시간 발표발표
Computer Graphics Applications40Source Source 코드코드 제출제출