Page 288 - The Definitive Guide to Building Java Robots
P. 288

Preston_5564C07.fm  Page 269  Monday, September 26, 2005  5:38 AM



                                                                               CHAPTER 7  ■  NAVIGATION  269



                            While moving inside the regions is no problem since we have been doing that, it’s navi-
                        gating from region to region inside the same room that we have not done. To help me with that,
                        I’ll create a new object called, simply enough, Room.
                            A Room will connect and orient all the regions in it relative to one another. I will do this by
                        connecting them with edges. This is convenient since we already have edges as DistanceVectors.
                        I will always construct the distance vectors so they are measured from each region’s center
                        point. To illustrate the creation of the region map in a real environment (my basement), see
                        Figure 7-12.






































                        Figure 7-12. The basement model

                            The next step is to create a data structure that can represent this, called Room. The Room
                        class, like the region class, has regions as vertices and edges, which will be DistanceVectors.
                        I have added a sample Room in the static method called getBasement(), which defines the
                        room in the previous figure. See Example 7-17.














                   97022d2480fe4a63cfdfa123a6e70098
   283   284   285   286   287   288   289   290   291   292   293