2016-09-20 16 views
0

明らかに、他の手段で描くことができるどのような形も、カメによって描くことができます。円や四角はあまりないタートルで超楕円を描く

rt 1 fd .0 

if ticks mod 100 = 0 [rt 90] 
fd 1 

スーパー楕円簡単です。 (規則的な省略記号も自明ではありません) The Wikipedia article on super-ellipsesトピックについて最新表示が必要な場合は、

ご了承ください。

亀のカメを使用すると、亀の動きから出てくる超楕円を作る方法がありますか?

+0

あなたは通常の省略記号は自明ではないと言いますが、どのように描くことができるのでしょうか? – gue

+0

かなり少しlonの答えが好きだった。 –

+0

setposで問題を起こしているのは何ですか?あなたは方程式を持っています。 –

答えて

1

私はそれの1/4を持っています、私はあなたが他の3つを一緒に置くことができると思います。 nの他の値はここではテストされません。 (Wikiの表記法と、phiをすべて回転させる角度として使用します)。また、リセット・ティックの配置は、ペン・ダウンではうんざりです。

to go2 
    clear-all 
    reset-ticks 
    let a 6 
    let b 5 
    let phi 0 
    let n 3.5 
    create-turtles 1 [ 
    let iNdx 1 
    repeat 90 [ 
     show iNdx 
     show cos(iNdx) 
     if cos(iNdx) > 0 and sin(iNdx) > 0 [ 
     let tx (a * (cos(iNdx)^(2/n))) 
     let ty (b * (sin(iNdx)^(2/n))) 
     let tx2 tx * cos(phi) - ty * sin(phi) 
     let ty2 tx * sin(phi) + ty * cos(phi) 
     setxy tx2 ty2 
     ] 
     pen-down 
     set iNdx iNdx + 1 
     ] 
    ] 
    end 

は、楕円は単純に見えますが、あなたは裁判官

to go 
    clear-all 
    reset-ticks 
    let a 6 
    let b 5 
    let phi 45 
    create-turtles 1 [ 

    let iNdx 1 
    repeat 360 [ 
     let tx (a * cos(iNdx)) 
     let ty (b * sin(iNdx)) 
     let tx2 tx * cos(phi) - ty * sin(phi) 
     let ty2 tx * sin(phi) + ty * cos(phi) 
     setxy tx2 ty2 
     pen-down 
     set iNdx iNdx + 1 
     ] 
    ] 
    end 

手順として一般化し、簡素化すること。

to Super-ellipse [x y a b m n] 
create-turtles 1 [ 
let iNdx 1 
repeat 360 [ 
setxy (x + (abs cos iNdx)^(2/m) * a * (sgn cos iNdx)) 
     (y + (abs sin iNdx)^(2/n) * b * (sgn sin iNdx)) 
pendown 
set iNdx iNdx + 1] 
] 
end 
+0

非常に素敵な私はそれをちょっとびっくりし、あなたの許可を得て完全な楕円を作るものを作りました。私はそれをあなたの答えに加えます。 –

+0

あなたはbetchaです。私の答えは改善のために叫ぶ! –

+0

私はそれを追加し、私の競合する答えを削除しました。 –

0

一般的な別の回答の形式は、私が考えていたようなものを作り出すようです。ペンが焦点の1つに近づくほど、図面は正方形に近くなります。 n <超楕円が1つ達成されません。

globals[c] 
breed [pens pen] 
breed [foci focus] 
foci-own [dist distx disty] 
to setup 
ca 
create-pens 1 [set heading 45 fd 10 pendown set C self] 
;create-foci 1 [setxy (random-xcor/2) (random-ycor/2)] 
create-foci 1 [setxy 10 10] 
create-foci 1 [setxy 10 -10] 
create-foci 1 [setxy -10 -10] 
create-foci 1 [setxy -10 10] 
end 

to go 
repeat 5100 
    [ 
    ask foci [ 
      set dist distance c 
      set distx xcor - [xcor] of c 
      set disty ycor - [ycor] of c 
     ] 
ask c 
[ 
     set heading 90 + atan (sum [distx/dist] of foci/sum [dist] of foci) 
         (sum [disty/dist] of foci/sum [dist] of foci) 
     FD .0125 
    ] 
    ] 
end 
関連する問題