# Circular Path Example ### 1 collaborator Uri Wilensky (Author)

### Tags

code example

Tagged by Reuven M. Lerner over 7 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 860 times • Downloaded 44 times • Run 2 times Download this modelEmbed this model

Click to Run Model

```globals [radius]

to setup
clear-all
;; make 12 turtles, equally spaced in heading
create-ordered-turtles 12 [
;; move to edge of circle
;; turn to face clockwise
rt 90
;; bigger turtles are easier to see
set size 3
;; thicker line is easier to see
set pen-size 3
;; leave a trail
pen-down
]
reset-ticks
end

to go-distance
ask turtles [ arc-forward-by-dist step-size ]
tick
end

to go-angle
ask turtles [ arc-forward-by-angle arc-angle ]
tick
end

;; This is the core procedure.  It moves the turtle to the next point
;; on the circle, the given distance along the curve.

to arc-forward-by-dist [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
rt theta / 2
;; go there
fd dist
;; turn to face tangent to the circle
rt theta / 2
end

to arc-forward-by-angle [angle]
;; turn to face the next point we're going to
rt 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
rt angle / 2
end

; Public Domain:
; To the extent possible under law, Uri Wilensky has waived all
; copyright and related or neighboring rights to this model.
```

There are 9 versions of this model.

Uri Wilensky over 7 years ago Updated version tag Download this version
Uri Wilensky over 8 years ago Updated to NetLogo 5.0 Download this version