在 Netlogo 中画一个半圆

Draw a semicircle in Netlogo

我想创建一个半圆,我的半圆的圆心在世界的尽头,例如我想要我的半圆的圆心在50,20的位置,从20到-20 . 我尝试这样做,但出现异常:

The point [ 60 , 20 ] is outside of the boundaries of the world and wrapping is not permitted in one or both directions.

to mysemicircle
  let cx 50                ;; x coordinate of patch you want to circle
  let cy 20                ;; y coordinate of patch you want to circle
  let r 10                ;; radius of the circle you want
  let p2r ( 2 * pi * r )  ;; get circumference of the circle
  let step p2r / 360      ;; make step lengths 1/360th of the circumference
  crt 1 [                 ;; create a single drawing turtle
    setxy cx + r cy       ;; move it to the highlight patch + the radius
    pd                    ;; put the pen down
    set heading 0         ;; make it face along the tangent
    while [ p2r > 0 ] [   ;; make the turtle continue to move until the circle is drawn
      lt 1                
      fd step            
      set p2r p2r - step 
      set color white   
    ]
  ]

end

并且如果我使用 cx 40 和 cy 20,则圆不是从 y -20 到 y 20,而是仅从 y 0 到 y 20。 我怎样才能做到这一点?

也许带参数的过程会更好,比如:

to setup
  ca  
  resize-world -20 20 -20 20
  draw-semi-circle 0 0 15 45 blue
  draw-semi-circle 5 5 5 270 red
  draw-semi-circle -10 -10 8 135 green
  reset-ticks
end

to draw-semi-circle [ x y r a col ] 
  ; Give arguments for x, y, radius, and angle of the semicircle
  let half-p ( pi * r ) 
  let step half-p / 180
  ask patch x y  [
    set pcolor col
  ]
  crt 1 [  
    setxy x y
    set heading a   
    lt 90
    set color col
    back r 
    pd                    
    fd 2 * r
    rt 90
    while [ half-p > step ] [  
      rt 1                
      fd step            
      set half-p half-p - step  
    ]
  ]
end

要获得如下输出: