150 likes | 158 Views
Geometry for Page Flipping. A project for Prof. George Wolberg’s Computer Graphics class Spring 2008. A. B. C. D. F. E. RightCorner. case (triangle). A = Mouse point (x,y) dx = AB dy = BD = a+b b = AC=CD a = BC. A. B. C. D. F. E. Point C. dx 2 +a 2 = b 2 a = dy - b
E N D
Geometry for Page Flipping A project for Prof. George Wolberg’s Computer Graphics class Spring 2008
A B C D F E RightCorner. case (triangle) A = Mouse point (x,y) dx = AB dy = BD = a+b b = AC=CD a = BC
A B C D F E Point C • dx2 +a2 = b2 • a = dy - b • Apply 2 to 1 • dx2 + (dy – b)2 = b2 • dx2 + (dy2– 2bdy + b2) = b2 • dx2 + dy2 = 2bdy • 4. b = (dx2 + dy2)/2dy ∴ Point C : x = width y = mouse point + a
A B C D F E Point F • tan∠CAB = tan ∠FAE • a/dx = ?(FE)/dy • ?(FE) = a/dx * dy ∴ Point F : x = mouse point - ?(FE) y = height
Check list K • AG ≤ width • AJ < width • to avoid stretching. • F > G • to avoid tearing • C > K • to check lifted part • is triangle or quadrilateral A J C D G F
RightCorner. case (quadrilateral 1) C Point D A = Mouse point (x,y) dx = AB a = BC d = sqrt(dx2+a2) = AC D F H • cos∠DAE = cos ∠CAB • ? (AE)/h = dx/d • ?(AE) = dx/d * h • sin∠DAE = sin ∠CAB • ?(DE)/h = a/d • ? (DE) = a/d * h G A B E ∴ Point D : x = mouse point + AE y = mouse point + DE
C Point H ∠DFG = ∠CAB ∠DFG = ∠HDG D F H • tan∠CAB = tan ∠HDG • ?(GH)/DG = a/dx • ?(GH) = a/dx * DG G A B E ∴ Point H : x = point D + ?(GH) y = top edge
Check list • AL ≤ width • AK < width • to avoid stretching. • J > K • to avoid tearing A L K J
H F D B G J E A RightCorner. case (quadrilateral 2) A = Mouse point (x,y) dx = GJ = a+b b = AE=EJ a = GE dy = AG
H F D B G J E A Point E • dy2 +a2 = b2 • a = dx - b • Apply 2 to 1 • dy2 + (dx – b)2 = b2 • dy2 + (dx2– 2bdx + b2) = b2 • dy2 + dx2 = 2bdx • 4. b = (dy2 + dx2)/2dx ∴ Point E : x = mouse point + a y = height
H F D B G K E J A Point D • cos∠EAG = cos ∠AKG • cos ∠ADF • ? (DF)/h = dy/b • ?(DF) = dy/b * h • sin∠EAG = sin ∠ADF • ?(AF)/h = a/b • ? (AF) = a/b * h ∴ Point D : x = mouse point + DF y = mouse point + AF
C H M D B Point H dx = DB = a+b b = DH=HM a = CH dy = CD • dy2 +a2 = b2 • a = dx - b • Apply 2 to 1 • dy2 + (dx – b)2 = b2 • dy2 + (dx2– 2bdx + b2) = b2 • dy2 + dx2 = 2bdx • 4. b = (dy2 + dx2)/2dx ∴ Point H : x = point D + a y = top edge
Check list L H D • DL ≤ width • AN < width • G < J • to avoid stretching. • H > L • to avoid tearing G N J A
Texture Mapping A(0,0) B(1,0) 1.Draw page outline glTexCoord2f(D) glTexCoord2f(A) glTexCoord2f(B) glTexCoord2f(C) glTexCoord2f(E) 2.Draw lifted page glTexCoord2f(F) glTexCoord2f(C) glTexCoord2f(E’) F(0.1) C(0.BC/H) E’(FE/W,1) D(0,1) E(DE/W,1)
B(AB/W,0) E(0,0) C(DF/W,1) F(0,1) A(0,0) 1.Draw main quadrilateral glTexCoord2f(D) glTexCoord2f(A) glTexCoord2f(B) glTexCoord2f(C) 2.Draw lifted page glTexCoord2f(F) glTexCoord2f(E) glTexCoord2f(B’) glTexCoord2f(C’) B’(EB/W,0) C’(FC/W,1) D(0,1)