globals

globals preview image

1 collaborator

Default-person Peter Nikolyuk (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 3D 6.3.0 • Viewed 69 times • Downloaded 5 times • Run 0 times
Download the 'globals' modelDownload this modelEmbed this model

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


## 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

Please start the discussion about this model! (You'll first need to log in.)

Click to Run Model

globals [ radius ]

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

  create-turtles 12 [
    ;; move to a random point on the sphere
    tilt-up ( random 180 ) - 90
    fd radius
    ;; 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
  ]
  reset-ticks
end 

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

to go-angle
  ask turtles [
    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 


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

There is only one version of this model, created 11 months ago by Peter Nikolyuk.

Attached files

File Type Description Last updated
globals.png preview Preview for 'globals' 11 months ago, by Peter Nikolyuk Download

This model does not have any ancestors.

This model does not have any descendants.