# Spherical Path Example 3D

### 1 collaborator

Uri Wilensky (Author)

### Tags

(This model has yet to be categorized with any tags)
Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 3D 4.1pre7 • Viewed 382 times • Downloaded 15 times • Run 0 times

### WHAT IS IT?

This shows how to make turtles move along a perfect sphere. The first procedure moves turtles based a user-defined distance to be travelled; the second moves then based on a user-defined degree measure.

### HOW IT WORKS

We use trigonometry to calculate the turtle's successive positions on the circle.

### RELATED MODELS

Turtles Circling, Circular Path Example

## Comments and Questions

Click to Run Model

```globals [ radius ]

to setup
clear-all
set radius ( world-width - 2 ) / 2

crt 12 [
;; move to a random point on the sphere
tilt-up ( random 180 ) - 90
;; lie tangent to the sphere
tilt-down 90
;; turn again so that not all turtles are moving
;; to north and south poles
rt random 360
pen-down
]
end

to go-distance
arc-forward-by-distance step-size
lt random wiggle-range rt random wiggle-range
]
tick
end

to go-angle
arc-forward-by-angle arc-angle
lt random wiggle-range rt random wiggle-range
]
tick
end

;; This procedure moves the turtle to the next point
;; on the sphere the given distance along the curve.

to arc-forward-by-distance [dist] ;; turtle procedure
;; calculate how much of an angle we'll be turning through
;; (essentially converting radians to degrees)
let theta dist * 180 / ( pi * radius )
;; turn to face the next point we're going to
tilt-down theta / 2
;; go there
fd dist
;; turn to face tangent to the circle
tilt-down theta / 2
end

;; This procedure moves the turtle to the next point
;; on the sphere the given angle measure along the curve.

to arc-forward-by-angle [angle] ;; turtle procedure
;; turn to face the next point we're going to
tilt-down angle / 2
;; calculate the distance we'll have to move forward
;; in order to stay on the circle. Go there.
fd 2 * radius * sin (angle / 2)
;; turn to face tangent to the circle
tilt-down angle / 2
end

; Copyright 2007 Uri Wilensky. This code may be freely copied, distributed,
; altered, or otherwise used by anyone for any legal purpose.
```

There are 3 versions of this model.