Circular Path Example

1 collaborator

Uri Wilensky (Author)

Tags

code example

Tagged by Reuven M. Lerner almost 10 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 966 times • Downloaded 53 times • Run 2 times

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 9 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 12 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 12 years ago Circular Path Example Download this version

Attached files

File Type Description Last updated
Circular Path Example.png preview Preview for 'Circular Path Example' almost 10 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.