請問程式碼是哪裡出了問題呢?? - BBS
By Isabella
at 2014-06-09T00:22
at 2014-06-09T00:22
Table of Contents
以下為程式碼
------------------------------------------------------------------------------
> with(plots);
> with(plottools);
> with(geometry);
> Sierpinski := proc (x1, y1, x2, y2, x3, y3, x4, y4, n)
if n <= 1 then
[(1/2)*x1+(1/2)*x2, (1/2)*y2+(1/2)*y3, 0, (1/3)*x2-(1/3)*x1]
else
Sierpinski(x1, y1, x2, y2, x3, y3, x4, y4, n-1),
Sierpinski(x1, (1/3)*y1+(2/3)*y4, (2/3)*x4+(1/3)*x3, (1/3)*y1+(2/3)*y4, (2/3)*x4+(1/3)*x3,
y4, x4, y4, n-1),
Sierpinski(x1, (1/3)*y4+(2/3)*y1, (2/3)*x4+(1/3)*x3,
(1/3)*y4+(2/3)*y1, (2/3)*x4+(1/3)*x3, (1/3)*y1+(2/3)*y4, x1,
(1/3)*y1+(2/3)*y4, n-1),
Sierpinski(x1, y1, (2/3)*x4+(1/3)*x3, y1,
(2/3)*x4+(1/3)*x3, (1/3)*y4+(2/3)*y1, x1, (1/3)*y4+(2/3)*y1, n-1),
Sierpinski((2/3)*x4+(1/3)*x3, y1, (1/3)*x1+(2/3)*x2, y1, (1/3)*x1+(2/3)*x2,
(1/3)*y4+(2/3)*y1, (2/3)*x4+(1/3)*x3, (1/3)*y4+(2/3)*y1, n-1),
Sierpinski((1/3)*x1+(2/3)*x2, y1, x2, y2, x2, (2/3)*y2+(1/3)*y3,
(1/3)*x1+(2/3)*x2, (1/3)*y4+(2/3)*y1, n-1),
Sierpinski((1/3)*x1+(2/3)*x2,
(1/3)*y4+(2/3)*y1, x2, (2/3)*y2+(1/3)*y3, x2, (1/3)*y2+(2/3)*y3,
(2/3)*x3+(1/3)*x4, (1/3)*y2+(2/3)*y3, n-1),
Sierpinski((2/3)*x3+(1/3)*x4,
(1/3)*y2+(2/3)*y3, x2, (1/3)*y2+(2/3)*y3, x3, y3, (2/3)*x3+(1/3)*x4, y3,
n-1),
Sierpinski((2/3)*x4+(1/3)*x3, (1/3)*y1+(2/3)*y4, (2/3)*x3+(1/3)*x4,
(1/3)*y2+(2/3)*y3, (2/3)*x3+(1/3)*x4, y3, (2/3)*x4+(1/3)*x3, y4, n-1)
end if
end proc;
>
%;
> Tlist := [Sierpinski(0, 0, 512, 0, 512, 512, 0, 512, 2)];
print(`output redirected...`); # input placeholder
[[ 512] [256 1280 512] [256 512]
[[256, 256, 0, ---], [---, ----, 0, ---], [---, 256, 0, ---],
[[ 3 ] [ 3 3 9 ] [ 3 9 ]
[256 256 512] [ 256 512] [1280 256 512]
[---, ---, 0, ---], [256, ---, 0, ---], [----, ---, 0, ---],
[ 3 3 9 ] [ 3 9 ] [ 3 3 9 ]
[1280 512] [1280 1280 512] [ 1280 512]]
[----, 256, 0, ---], [----, ----, 0, ---], [256, ----, 0, ---]]
[ 3 9 ] [ 3 3 9 ] [ 3 9 ]]
>
> n := nops(Tlist);
p[i] := hexahedron([Tlist[i][1], Tlist[i][2], Tlist[i][3]], Tlist[i][4]);
plots[display]([seq(p[i], i = 1 .. n)]);
%;
9
Error, (in plots/polyhedraplot) first argument must be a list of three tuples
Error, (in plots:-display) expecting plot structures but received: [p[1],
p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]]
------------------------------------------------------------------------------
最後三行是所顯示的問題
有哪位高手大大可以告訴我是哪裡出了問題
怎麼改嗎??
謝謝!
--
------------------------------------------------------------------------------
> with(plots);
> with(plottools);
> with(geometry);
> Sierpinski := proc (x1, y1, x2, y2, x3, y3, x4, y4, n)
if n <= 1 then
[(1/2)*x1+(1/2)*x2, (1/2)*y2+(1/2)*y3, 0, (1/3)*x2-(1/3)*x1]
else
Sierpinski(x1, y1, x2, y2, x3, y3, x4, y4, n-1),
Sierpinski(x1, (1/3)*y1+(2/3)*y4, (2/3)*x4+(1/3)*x3, (1/3)*y1+(2/3)*y4, (2/3)*x4+(1/3)*x3,
y4, x4, y4, n-1),
Sierpinski(x1, (1/3)*y4+(2/3)*y1, (2/3)*x4+(1/3)*x3,
(1/3)*y4+(2/3)*y1, (2/3)*x4+(1/3)*x3, (1/3)*y1+(2/3)*y4, x1,
(1/3)*y1+(2/3)*y4, n-1),
Sierpinski(x1, y1, (2/3)*x4+(1/3)*x3, y1,
(2/3)*x4+(1/3)*x3, (1/3)*y4+(2/3)*y1, x1, (1/3)*y4+(2/3)*y1, n-1),
Sierpinski((2/3)*x4+(1/3)*x3, y1, (1/3)*x1+(2/3)*x2, y1, (1/3)*x1+(2/3)*x2,
(1/3)*y4+(2/3)*y1, (2/3)*x4+(1/3)*x3, (1/3)*y4+(2/3)*y1, n-1),
Sierpinski((1/3)*x1+(2/3)*x2, y1, x2, y2, x2, (2/3)*y2+(1/3)*y3,
(1/3)*x1+(2/3)*x2, (1/3)*y4+(2/3)*y1, n-1),
Sierpinski((1/3)*x1+(2/3)*x2,
(1/3)*y4+(2/3)*y1, x2, (2/3)*y2+(1/3)*y3, x2, (1/3)*y2+(2/3)*y3,
(2/3)*x3+(1/3)*x4, (1/3)*y2+(2/3)*y3, n-1),
Sierpinski((2/3)*x3+(1/3)*x4,
(1/3)*y2+(2/3)*y3, x2, (1/3)*y2+(2/3)*y3, x3, y3, (2/3)*x3+(1/3)*x4, y3,
n-1),
Sierpinski((2/3)*x4+(1/3)*x3, (1/3)*y1+(2/3)*y4, (2/3)*x3+(1/3)*x4,
(1/3)*y2+(2/3)*y3, (2/3)*x3+(1/3)*x4, y3, (2/3)*x4+(1/3)*x3, y4, n-1)
end if
end proc;
>
%;
> Tlist := [Sierpinski(0, 0, 512, 0, 512, 512, 0, 512, 2)];
print(`output redirected...`); # input placeholder
[[ 512] [256 1280 512] [256 512]
[[256, 256, 0, ---], [---, ----, 0, ---], [---, 256, 0, ---],
[[ 3 ] [ 3 3 9 ] [ 3 9 ]
[256 256 512] [ 256 512] [1280 256 512]
[---, ---, 0, ---], [256, ---, 0, ---], [----, ---, 0, ---],
[ 3 3 9 ] [ 3 9 ] [ 3 3 9 ]
[1280 512] [1280 1280 512] [ 1280 512]]
[----, 256, 0, ---], [----, ----, 0, ---], [256, ----, 0, ---]]
[ 3 9 ] [ 3 3 9 ] [ 3 9 ]]
>
> n := nops(Tlist);
p[i] := hexahedron([Tlist[i][1], Tlist[i][2], Tlist[i][3]], Tlist[i][4]);
plots[display]([seq(p[i], i = 1 .. n)]);
%;
9
Error, (in plots/polyhedraplot) first argument must be a list of three tuples
Error, (in plots:-display) expecting plot structures but received: [p[1],
p[2], p[3], p[4], p[5], p[6], p[7], p[8], p[9]]
------------------------------------------------------------------------------
最後三行是所顯示的問題
有哪位高手大大可以告訴我是哪裡出了問題
怎麼改嗎??
謝謝!
--
Tags:
BBS
All Comments
By Puput
at 2014-06-10T19:03
at 2014-06-10T19:03
By Charlotte
at 2014-06-12T13:44
at 2014-06-12T13:44
Related Posts
PC接到無線分享器 做家庭WIFI 怎麼辦?
By Tom
at 2014-05-26T23:23
at 2014-05-26T23:23
mysql無法正常啟動
By Tristan Cohan
at 2014-05-17T03:10
at 2014-05-17T03:10
mysql無法正常啟動
By Lily
at 2014-05-15T02:29
at 2014-05-15T02:29
bluebat - 三則閃電講
By Belly
at 2014-04-22T10:51
at 2014-04-22T10:51
pf的設定
By Tristan Cohan
at 2014-03-27T14:18
at 2014-03-27T14:18