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

## NetLogo Models Library:3D/Sample Models

 Note: If you download the NetLogo application, every model in the Models Library is included.

## WHAT IS IT?

This model is a 3D version of a surface-walking algorithm used in "Surface Walk 2D". Turtles approximate a user-defined surface using a simple algorithm that considers the turtle's current position relative to neighboring surface patches.

## HOW IT WORKS

Turtles exist in a world that consists of two different kinds of patches: surface and non-surface. Turtles follow two basic rules in order to walk along the patch-defined surface:

1) Look for opposite neighboring patches. If the turtle is currently on a surface patch, it will look for a non-surface one, and vice versa. 2) Of those neighboring patches of opposite type, identify the one that requires the smallest change in turtle angle for the turtle to face. 3) Adjust pitch and heading halfway to the patch that requires the smallest change in angle to face and take a step.

Why does this algorithm work? Consider any perturbation along a flat surface (in the case of 2D, a curve or angle along an otherwise straight line). In order to traverse the perturbation and remain on the surface, a turtle needs to find and remain on the 'edge' of the surface, and maintain its direction while traveling along this edge. Since turtles in NetLogo always report being on only one patch (the one that the center of their body is over), we maintain the turtle's position along the edge by having it search for a patch that is of opposite type to the patch it is positioned over (Rule 1).

Rule 2 enables the turtles to travel along that edge while maintaining their current direction. Consider a surface in 2D: turtles are able to travel along that surface in one of two opposite directions (for example, they can walk along a circle in either a clockwise or counterclockwise direction). If a surface is flat, a turtle need not change its heading at all to continue to travel in the same direction along that surface. But, if the surface is curved or has an angle, then in order to continue to stay along the edge of the surface the turtle must change its heading. If it changes its heading exactly 180 degrees, it will reverse its direction of travel. But whether the angle is concave or convex, it will be of some measure between 0 and 360 degrees (non-inclusive). Then the heading change required to continue along the surface without reversing the direction of travel will be less than that required to reverse direction.

Finally, Rule 3 reduces the 'weaving' effects produced by turtles moving toward surface and non-surface patches in order to remain close to the edge by having turtles actually point only halfway to the patch of interest.

In 3D versions of this surface-walking algorithm, the same rules are used as in the 2D version, but the way to determine the angle between a turtle's current heading and the nearest opposite patch is a little more complicated. Because there are two angle measures, heading and pitch, we use the inverse dot product to determine the angle between a turtle's heading and a given patch. For more detail, it may help to look through the "Trig for Angle Calculations" section of the Code tab or visit the "Geometric Interpretation" of the dot product entry at Wikipedia: https://en.wikipedia.org/wiki/Dot_product.

## HOW TO USE IT

NUMBER-OF-TURTLES: Allows the user to adjust the number of turtles that will appear along the shape surface when SETUP is pressed. STEP-SIZE: Allows the user to adjust how far each turtle moves forward during each step. SURFACE-SHAPE: Allows the user to select the surface shape to appear when SETUP is pressed. COLORED-SURFACE?: Allows user to toggle whether the surface on which turtles will walk is colored red, or is invisible. SETUP: Sets up the environment by creating a surface and placing turtles along the surface. GO: Runs the model by asking turtles to walk along the surface. TRACE: Asks a random turtle to leave a trail.

## THINGS TO NOTICE

Try adjusting STEP-SIZE while the model is running. What happens to the motion of the turtles? What happens to their speed?

Do turtles behave differently on different types of surfaces? Try using the SURFACE-SHAPE chooser to test different shapes. Try creating your own.

Set the SURFACE-SHAPE chooser to "Sphere", and set NUMBER-OF-TURTLES to 1. Run the model and observe the motion of that one turtle over the sphere. Is its motion what you would expect? Try using the TRACE button to trace the turtle's trajectory over the surface, or try different surfaces.

## THINGS TO TRY

What might happen if the STEP-SIZE is set to 1 or larger?

Currently, turtles turn half of the way to the edge patch that they identify. What happens if they turn the whole way?

Select "Mickey Mouse" from the SURFACE-SHAPE chooser. SETUP and tell the model to GO. What happens to turtles when they pass over the acute angles where Mickey's ears meet his head? Try adjusting the STEP-SIZE slider while the model is running to investigate.

When does the surface-walking algorithm fail? Why? Does changing the world's resolution effect turtle motion?

## EXTENDING THE MODEL

Currently, turtles seek the surface edge by seeking patches that are classified in certain ways. Find and implement another way that patches can be identified or that turtles can identify edge patches.

Can there be more than two types or classifications of surface patches? When would this be useful?

Try using `stamp` to trace the trajectory of a turtle over different kids of surfaces. How might one describe surface-walking accuracy?

The surface-walking algorithm used in this model fails for surfaces (or gaps in surfaces) that are only one patch wide. Why? How might this be fixed?

## NETLOGO FEATURES

Note the use of `towards` and `towards-pitch` to compute headings and pitches and `min-one-of` to make a choice between competing patches.

## RELATED MODELS

Surface Walking (2D NetLogo model)

## HOW TO CITE

If you mention this model or the NetLogo software in a publication, we ask that you include the citations below.

For the model itself:

Please cite the NetLogo software as: