Circular Path Example

Circular Path Example preview image

1 collaborator

Uri_dolphin3 Uri Wilensky (Author)

Tags

code example 

Tagged by Reuven M. Lerner almost 12 years ago

Model group CCL | Visible to everyone | Changeable by group members (CCL)
Model was written in NetLogo 5.0.4 • Viewed 1111 times • Downloaded 105 times • Run 2 times
Download the 'Circular Path Example' modelDownload this modelEmbed this model

Do you have questions or comments about this model? Ask them here! (You'll first need to log in.)


Comments and Questions

Click to Run Model

globals [radius]

to setup
  clear-all
  set radius max-pxcor - 2
  ;; make 12 turtles, equally spaced in heading
  create-ordered-turtles 12 [
    ;; move to edge of circle
    fd radius
    ;; 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.

Uploaded by When Description Download
Uri Wilensky over 11 years ago Updated to NetLogo 5.0.4 Download this version
Uri Wilensky about 12 years ago Updated version tag Download this version
Uri Wilensky almost 13 years ago Updated to NetLogo 5.0 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Updated from NetLogo 4.1 Download this version
Uri Wilensky over 14 years ago Model from NetLogo distribution Download this version
Uri Wilensky over 14 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' over 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.