Home
Help
Resources
Extensions
FAQ
NetLogo Publications
Donate

Models:
Library
Community
Modeling Commons

Beginners Interactive NetLogo Dictionary (BIND)
NetLogo Dictionary

User Manuals:
Web
Printable
Chinese
Czech
Farsi / Persian
Japanese
Spanish

# Line of Sight Example

 If you download the NetLogo application, this model is included. You can also Try running it in NetLogo Web

## WHAT IS IT?

On a perfectly flat landscape, you can see all the way to the horizon. But if the landscape has hills, your view of some of the land in front of you may be blocked. This code example shows how to simulate this using turtles moving over a patch landscape of varying elevation.

## HOW IT WORKS

Each patch has an elevation. Every patch that a turtle can "see" from its current location and elevation is considered to be in the turtle's "line of sight." To show this, a colored dot is placed on the patch. The patches visible to each turtle are determined by the turtle's heading, the MAXIMUM-VISIBILITY slider (how many patches ahead each turtle can see if it is unobstructed) and the elevations of the patches in between.

Each turtle looks ahead at the patches up to MAXIMUM-VISIBILITY away. If the angle from the location of the turtle to the top of the patch is greater than the angle to the last visible patch then there is a line from the turtle to the patch that does not intersect any of the other patches, thus it is in the "line of sight" of the turtle.

While all six turtles show their line of sight with dots, the orange turtle's line of sight is depicted with a plot, as well. The plot shows the elevation of the MAXIMUM-VISIBILITY patches in front of the turtle, with visible patches drawn as orange bars. (Thus if the three leftmost bars are drawn in orange, the elevations allow the orange turtle to see only three patches ahead.)

## EXTENDING THE MODEL

Make each turtle able to see around it in all directions, not only the single direction in which it is facing.