Sample15
         
         to sample15 :baserad
    local "fixedpoint
    make "fixedpoint (* :baserad 1.2)
         
    (local "po.xx "po.yy "radius)
         
    penup
    (for "loop 0 360 [
       make "po.xx (* :baserad cos :loop)
       make "po.yy (* :baserad sin :loop)
       make "radius sqrt + (^ - :po.xx :fixedpoint 2) (^ :po.yy 2)
       setxy sentence :po.xx :po.yy
       pendown
       stampoval :radius :radius
       penup
    ] 10)
    pendown
end
          
         
           
          
          
          一般的に「心臓形曲線(Cardioid)」と呼ばれている図形です。 
         sample15 50 として実行しています。 
         円の中心が、po.xxとpo.yyを中心とする半径baseradの円の円周上を、移動して描かれています。 
         その中心po.xxとpo.yyから定点fixedpointを通る円を描きます。 
         fixedpointは、単にbaseradから1.2倍された距離にあります。 
         描画する円の半径は、po.xxからfixedpointへの長さです。 
         半径radius = sqrt ((:po.xx - :fixedpoint) ^ 2 + :po.yy ^
         2) と書いたほうが、判りやすいでしょうか。 
          
          
          
          
          
          
         
         Sample16
         
         to sample16 :baserad [:x 1] [:y 1] 1
    (local
    "current.xy
    "pointdist
    "head
    "fixedpoint.x "fixedpoint.y
    "po.xx "po.yy
    "radius
    )
         
    name 1.2 "pointdist
    make "current.xy getxy
    make "head heading
    make "fixedpoint.x (+ item 1 :current.xy (* * :baserad :pointdist cos :head))
    make "fixedpoint.y (+ item 2 :current.xy (* * :baserad :pointdist sin :head))
         
    penup
    (for "loop 0 360 [
       make "po.xx (+ item 1 :current.xy (* :baserad cos :loop))
       make "po.yy (+ item 2 :current.xy (* :baserad sin :loop))
       make "radius sqrt + (^ - :po.xx :fixedpoint.x 2) (^ - :po.yy :fixedpoint.y 2)
       setxy sentence :po.xx :po.yy
       pendown
       circle * :radius :x (* :radius :y)
       ;stampoval * :radius :x (* :radius :y)
       penup
    ] 10)
    pendown
end 
         
          
         
         1)(sample16 40 0.8) 
         2)rt 90 (sample16 40 1 0.5) 
         Sample15を、拡張してソラ豆とピーマンを描かせてみました。:-D 
         Sample15は、中心座標が固定でしたが、これは自由な位置に描ける様にしています。 
         しかも円の縦横比率を変更できるので、面白い図形が出来ますね。 
         circle * :radius :x (* :radius :y) 
         ;stampoval * :radius :x (* :radius :y) 
         上のcircle文を、コメントにして次の行のセミコロン記号(;)を、取って較べると違いが良く判ります。 
         
           
         
         
         
           
       |