Sector Area and Arc Length

Sector Area and Arc Length preview image

1 collaborator

Default-person Mighty Chen (Author)

Tags

(This model has yet to be categorized with any tags)
Visible to everyone | Changeable by everyone
Model was written in NetLogo 6.1.0 • Viewed 78 times • Downloaded 1 time • Run 0 times
Download the 'Sector Area and Arc Length' 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

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

Click to Run Model

globals [end?]
turtles-own [
  out-counter
  around-counter
  outer-ring-counter
  around-angle-counter
  home-counter
  going-out?
  going-around?
  going-home?
  current-radius
  current-degrees
  fill-area?
]

to setup
  clear-all
  ask patches [
    set pcolor white
  ]
  reset-ticks
  create-turtles 1 [
    set color red
    facexy 1 0
    pen-down
    set pen-size 2
    set size 1.5
    set out-counter 0
    set around-angle-counter 0
    set around-counter 0
    set home-counter 0
    set going-out? true
    set going-around? false
    set going-home? false
    set fill-area? false
    set current-radius radius
    set current-degrees 0
    set end? false
  ]
end 

to go
  if end? [
    stop
  ]
  ;; handle the state of which way i should be going
  ask turtles [
    ;; determine the state
    if going-out? and out-counter >= current-radius [
      set going-out? false
      set out-counter 0
      set going-around? true
      set pen-size 5 set color blue
      left 90
    ]

    if going-around? and around-angle-counter > central-angle [
      set going-around? false
      set around-angle-counter 0
      set going-home? true
      set pen-size 2
      set color red
      left 90
    ]

    if going-home? and home-counter >= current-radius [
      set going-home? false
      set home-counter 0
      set fill-area? true
      set color green
      set pen-size 1
      setxy 0 0 ; for floating point errors i think
      left 180 - central-angle
    ]

    ;; based on the state, move accordingly
    if going-out? [
      forward 0.1
      set out-counter out-counter + 0.1
    ]

    if going-around? [
      forward 2 * pi * current-radius / 360
      left 1
      set outer-ring-counter outer-ring-counter + (2 * pi * current-radius / 360)
      ; set around-counter around-counter + (2 * pi * current-radius / 360) * 1
      set around-angle-counter around-angle-counter + 1
    ]
    if going-home? [
      forward 0.1
      set home-counter home-counter + 0.1
    ]
    if fill-area? [
      if current-degrees >= central-angle [
        set color red
        set end? true
      ]
      forward radius
      rt 180
      forward radius
      rt 180
      set around-counter around-counter + (1 / 360) * pi * radius * radius ; one step is around 15 pixels?
      print radius / 15
      lt 1
      set current-degrees current-degrees + 1
    ]
  ]
  tick
end 

to-report calc-sa
  report central-angle / 360 * pi * radius * radius
end 

to-report calc-al
  report central-angle / 360 * 2 * pi * radius
end 

to-report outer-ring-walked
  let dist 0
  ask turtle 0 [
    set dist outer-ring-counter
  ]
  report dist
end 

to-report circle-walked
  let dist 0
  ask turtle 0 [
    set dist around-counter
  ]
  report dist
end 

There are 18 versions of this model.

Uploaded by When Description Download
Mighty Chen 5 months ago update default slider values Download this version
Mighty Chen 5 months ago more accurate values Download this version
Mighty Chen 5 months ago emergency lol Download this version
Mighty Chen 5 months ago change turtle back to red at the end Download this version
Mighty Chen 5 months ago make it behave like lidar Download this version
Mighty Chen 5 months ago Reverted to older version Download this version
Mighty Chen 5 months ago prefer underestimate Download this version
Mighty Chen 5 months ago made granularity larger because it takes forever Download this version
Mighty Chen 5 months ago removed formulas Download this version
Mighty Chen 5 months ago removed weird logic Download this version
Mighty Chen 5 months ago sa and al based on radius Download this version
Mighty Chen 5 months ago add radius Download this version
Mighty Chen 5 months ago lol woops i want the initial to be 90 Download this version
Mighty Chen 5 months ago final ifnal ft death Download this version
Mighty Chen 5 months ago final Download this version
Mighty Chen 5 months ago abm-ified Download this version
Mighty Chen 5 months ago hacky workaround for wait Download this version
Mighty Chen 5 months ago Initial upload Download this version

Attached files

File Type Description Last updated
Sector Area and Arc Length.png preview Preview for 'Sector Area and Arc Length' 5 months ago, by Mighty Chen Download

This model does not have any ancestors.

This model does not have any descendants.