Spherical Path Example 3D

Spherical Path Example 3D preview image

1 collaborator

Uri_dolphin3 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 414 times • Downloaded 22 times • Run 0 times
Download the 'Spherical Path Example 3D' 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

  crt 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
  ]
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 


; 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.

Uploaded by When Description Download
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 Spherical Path Example 3D Download this version

Attached files

File Type Description Last updated
Spherical Path Example 3D.png preview Preview for 'Spherical Path Example 3D' over 11 years ago, by Uri Wilensky Download

This model does not have any ancestors.

This model does not have any descendants.