Page 379 - Excel for Scientists and Engineers: Numerical Methods
P. 379

356                                        EXCEL: NUMERICAL METHODS



                   (6)  When all Nedges have been evaluated, if the number of crossings is odd,
                      the point lies inside the figure.


                   This  "inside  or  outside"  calculation  can  be  done  either  with  worksheet
               formulas or with a VBA custom function.  The following portion of a spreadsheet
               (Figure 15-1 6) illustrates the calculation using worksheet formulas.
































                      Figure 15-16.  Inside/outside determined by using worksheet formulas.
                (folder 'Chapter 15 Examples', workbook 'Inside or Outside Figure', sheet 'Single Point Diagram')

                   Note that, in the table of coordinates  of the  line segments that describe the
               figure (A6:B14 in Figure  15-16),  the coordinates of the initial point are repeated
               in line 15 so as to complete the figure.  (This of course is also necessary to create
               a  chart  of  the  figure.)  Thus  the  nine  rows  of  points  shown  in  Figure  15-16
               describe eight line segments.  That's why there are formulas in rows 7 through
               14, but  not  in row 6.  (It would be equally suitable to have formulas in rows 6
               through 13 and not in row 14.)
                   The formulas in row 7 are:
                   in cell C7:  =AND($A$19>A6,$A$19>A7)
                   in cell D7:  =IF(C7=TRUE,"",AND($A$I 9<A6,$A$19<A7))
                   in cell E7:  =IF(OR(D7=TRUE,D7=""),"",AND($B$19>B6,$B$19>87))
   374   375   376   377   378   379   380   381   382   383   384