Page 74 - DCAP313_LAB_ON_COMPUTER_GRAPHICS
P. 74

Lab on Computer Graphics



                   Notes         y is always decremented in each step, i.e. y k+1  = y k  – 1.
                                 x k+1  = x k  if S is selected, or x k+1  = x k  + 1 if SE is selected.
                                                    P k  = f(x k  + ½, y k  – 1)

                                                         2
                                                                   2
                                                                2
                                                                             2 2
                                                                         2
                                                      = b (x k  + ½)  + a (y k  – 1)  – a b
                                                                                  -
                                                                         2
                                                      =  b(x+ x+  1 4 )+ a(y -  2y+ 1) ab 2
                                                                                    2
                                                                      2
                                                           2
                                                         2
                                                                         k
                                                                             k
                                                           k
                                                               k
                                 If P k  > 0, select S:
                                                   P k+1   = f(x k  + ½, y k  – 2)
                                                    S
                                                      = b (x k  + ½)  + a (y k  – 2)  – a b
                                                                             2 2
                                                                   2
                                                         2
                                                                         2
                                                                2
                                                           2
                                                                                    2
                                                                         2
                                                                      2
                                                         2
                                                      =  b(x+ x+  1 4  )+ a(y -  4y+ 4) - ab 2
                                                                         k
                                                               k
                                                           x
                                                                             k
                                                  S
                                            S
                                                               2
                                 Change of  P  is:  DP  =  P k+1  -  P =a (3 - 2y )
                                                       S
                                                                     k
                                           k
                                                            k
                                                  k
                                 If P k  < 0, select SE:
                                                   P k+1  = f(x k  + 3/2, y k  – 2)
                                                    SE
                                                                 2
                                                      = b (x k  + 3/2)  + a (y k  – 2)  – a b
                                                                     2
                                                                              2 2
                                                         2
                                                                           2
                                                                                      2
                                                                           2
                                                         2
                                                                                    -
                                                           2
                                                      =  b(x+ 3x +9/4)+ a(y -  4y+ 4) ab 2
                                                                         2
                                                                           k
                                                           k
                                                                k
                                                                                k
                                                                 2
                                 Change of  P  is  DP  =  P k+1  – P k  = 2b (x k  + 1) + a (3 – 2y k )
                                                                          2
                                                        SE
                                            SE
                                                  SE
                                           k
                                                  k
                                 Calculate the changes of  DP :
                                                        k
                                 If S is selected,
                                                 Dp S k+1   = a (5 – 2y k )
                                                         2
                                                          S
                                                                S
                                                     S
                                                  D P  =  DP k+1  -  DP =2a 2
                                                   2
                                                    k
                                                                k
                                                 DP k+1   = 2b (x k  + 1) + a (5 – 2y k )
                                                    SE
                                                                   2
                                                          2
                                                           SE
                                                  2
                                                    SE
                                                                SE
                                                 D P  =  DP k+1  - DP =2a 2
                                                                k
                                                    k
                                 If SE is selected,
                                                    S
                                                 DP k+1   = a (5 – 2y k )
                                                         2
                                                  D P  =  DP k+1  -  DP =2a 2
                                                          S
                                                                S
                                                     S
                                                   2
                                                    k
                                                                k
                                                                    2
                                                    SE
                                                          2
                                                 DP k+1   = 2b (2x k  + 2) – a (5 – 2y k )
                                                 D P  =  DP k+1  -  DP =2(a +b )
                                                          SE
                                                                      2
                                                  2
                                                                         2
                                                    SE
                                                                SE
                                                    k
                                                                k
                                 Determine the boundary between region I and II:
                                                          dy      - bx
                                              Set f(x, y) = 0,   =
                                                          dx  a 2  1 x/a 2
                                                                     2
                                                                   -
                                                                   a 2             b 2
                                 When           dy/dx = –1, x =  x=      andy =         .
                                                                   2
                                                                  a+ b 2          a+ b 2
                                                                                   2
                                                            a 2            b 2
                                 At region I, dy/dx > – 1, x <    and y >       , therefore
                                                            2
                                                                           2
                                                           a+ b 2         a+ b 2
                                         Ê  2a 2    ˆ    Ê  b 2    ˆ
                                                        2
                                    SE
                                        2
                                  DP< b Á Á Ë  a+ b 2  +3˜ -  2a Á Á Ë  a+ b 2  -  1˜  = 2a  + 3b .
                                                                         2
                                                                             2
                                                                   ˜
                                    k
                                                    ˜
                                                            2
                                            2
                                                    ¯
                                                                   ¯
                                 Initial values at region II:
                                                           a 2              b 2
                                                    x 0  =       andy =
                                                                       0
                                                          2
                                                                           2
                                                          a+ b 2          a+ b 2
        68                                LOVELY PROFESSIONAL UNIVERSITY
   69   70   71   72   73   74   75   76   77   78   79