งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

งานนำเสนอกำลังจะดาวน์โหลด โปรดรอ

Chapter 3 Graphics Output primitives Part II

งานนำเสนอที่คล้ายกัน


งานนำเสนอเรื่อง: "Chapter 3 Graphics Output primitives Part II"— ใบสำเนางานนำเสนอ:

1 Chapter 3 Graphics Output primitives Part II
© 2005 Pearson Education

2 Circle drawing algorithm Ellipse drawing algorithm
Overview Circle drawing algorithm Ellipse drawing algorithm © 2005 Pearson Education

3 Circle Drawing Algorithm
Square Root Method Trigonometric Function Midpoint Circle Algorithm © 2005 Pearson Education

4 Square Root Method เราจะใช้สมการวงกลมที่มีจุดศูนย์กลางที่ (xc,yc) และรัศมี r โดยตรง วิธีวาด “วงกลม” อย่างง่ายที่สุด คือ กำหนดค่า x แล้วคำนวณจุดที่ตำแหน่ง y จาก Question : ข้อเสียของวิธีนี้คืออะไร ? © 2005 Pearson Education

5 Square Root Method © 2005 Pearson Education

6 Square Root Method © 2005 Pearson Education

7 Square Root Method Question : ข้อเสียของวิธีนี้คืออะไร ?
การคำนวณใช้เวลาของ CPU มาก ลักษณะของจุดภาพไม่ต่อเนื่อง (นิยามจุดภาพของวงกลมว่าอย่างไร) © 2005 Pearson Education

8 Trigonometric Function
เปลี่ยนสมการเส้นตรงที่เราคุ้นเคยให้เป็นสมการพิกัดเชิงขั้วดังนี้ © 2005 Pearson Education

9 Trigonometric Function
© 2005 Pearson Education

10 Midpoint Circle Algorithm
Mid point Algorithm Useful in drawing curves Determine the closest pixel to the curve path by using the mid-point between two candidate pixels Example, mid-point at xk+1 along a circular path © 2005 Pearson Education

11 Midpoint Circle Algorithm
การวาด วงกลมที่มีจุดศุนย์กลางอยู่ที่ (xc,yc) และรัศมี r สามารถทำได้โดยการเลื่อนวงกลมมาอยู่ที่จุดกำเนิด นั่นคือ (xc,yc) = (0, 0) แล้วหลังจากนั้นจึงเลื่อนไปยังจุดที่ถูกต้อง โดยการบวกจุดภาพ (x, y) ที่ได้ด้วยค่าพิกัด (xc,yc) © 2005 Pearson Education

12 Midpoint Circle Algorithm
คำถาม : สามารถลดเวลาในการคำนวณจุดภาพ (x, y ) เพื่อวาดวงกลมให้เต็มรูป ได้หรือไม่ © 2005 Pearson Education

13 Midpoint Circle Algorithm
ไม่จำเป็นต้องคำนวณหาจุดภาพ (x, y) ทุกจุดของเส้นรอบวง สามารถใช้กฎการสมมาตรเทียบกับแกน x = ±y และแกน x และ y ดังรูป (x, y) (y, x) (y, -x) (x, -y) (-x, -y) (-y, -x) (-y, x) (-x, y) © 2005 Pearson Education

14 Midpoint Circle Algorithm
เลื่อนวงกลมไปจุดกำเนิด คำนวณตัวแปรตัดสินใจเริ่มต้น p0 จากจุดเริ่มต้น (x0, y0) = (0, r) คำนวณจุดภาพที่ (xk+1, yk+1) เริ่มจาก k = 0 โดยใช้ตัวแปรตัดสินใจ pk กรณี pk < 0 คำนวณ xk+1 = xk +1 และ เลือก yk+1 = yk คำนวณ pk+1=pk + 2xk+1 +1 กรณี pk > 0 คำนวณ xk+1 = xk +1 และ เลือก yk+1 = yk-1 คำนวณ pk+1=pk + 2xk+1 +1 – 2yk+1 © 2005 Pearson Education

15 Midpoint Circle Algorithm
Algorithm … cont. สะท้อนจุดที่คำนวณได้ไปยังอีก 7 octants ที่เหลือโดยใช้กฎการสมาตร เลื่อนวงกลมไปยังจุดศูนย์กลางที่ต้องการ ทำซ้ำขั้นตอนที่ 3-5 ขณะที่ x<y © 2005 Pearson Education

16 Midpoint Circle Algorithm
Example จงวาดวงกลมที่มีรัศมี เท่ากับ 10 มีจุดศูนย์กลางอยู่ที่ (0, 0) © 2005 Pearson Education

17 Midpoint Circle Algorithm
Define the implicit of circle function as By putting a point (x, y) into the circle function if fcirc < 0 ; (x, y) is in the circle boundary, if fcirc = 0 ; (x, y) is on the circle boundary, if fcirc > 0 ; (x, y) is outside the circle boundary We can use the circle function as the decision parameter as same as Bresenham’s algorithm © 2005 Pearson Education

18 Midpoint Circle Algorithm
Deriving decision parameter สมมติเราได้วาดจุดภาพ (xk, yk) ไปแล้ว ต่อไปคือพิจารณา เลือกจุด yk และ yk-1 (why?) ซึ่งทำได้โดยคำนวณค่าตัว แปรตัดสินใจ pk ที่ midpoint © 2005 Pearson Education

19 Midpoint Circle Algorithm
© 2005 Pearson Education

20 Midpoint Circle Algorithm
Initial decision parameter © 2005 Pearson Education


ดาวน์โหลด ppt Chapter 3 Graphics Output primitives Part II

งานนำเสนอที่คล้ายกัน


Ads by Google