Hardware Reference
In-Depth Information
When you have built your field and fence, it should look something like Figure 2-8.
FIGURE.2-8 A field with a fence around it. The field is 10 blocks by 10 blocks in size.
Working out.the Corner Coordinates
of.the Field
In order to geo-fence the field with your program, you need to have an accurate record
of the coordinates of the corners of the field so that you can enter these numbers into
your Python program.
The easiest way to do this is to run your whereAmI.py program from earlier, then
have your player run to each corner of the field to get the x, y and z coordinates of each
corner. On a piece of paper, make a sketch of what you're building and write the coor-
dinates on the sketch. You will need them when you write your program. Remember
that the z coordinate gets bigger as your player moves south and smaller as your player
moves north, as you saw in Figure 2-1.
In Figure  2-9, you can see the coordinates of the field that I built when writing this
book. I have written down the coordinates for all four corners, as they are needed to
work out the smallest and biggest numbers in both the x and z directions. Note how
the smallest coordinates are at the top left corner of the field.
You need four numbers for your geo-fence program. First, you need to know the small-
est and biggest x coordinates, so work these out from your diagram. In the previous
example, the smallest x is 10 and the biggest x is 20. I have called the smallest x coor-
dinate X1 and the biggest x coordinate X2.
 
Search WWH ::




Custom Search