File:Von_koch_6_etapes.svg
維基百科,自由的 encyclopedia
此SVG文件的PNG预览的大小:600 × 174像素。 其他分辨率:320 × 93像素 | 640 × 186像素 | 1,024 × 297像素 | 1,280 × 371像素 | 2,560 × 742像素。
原始文件 (SVG文件,尺寸为600 × 174像素,文件大小:2 KB)
摘要
描述Von koch 6 etapes.svg |
English: von Koch snowflake curve after 6 steps (4,097 points); initially created with Scilab, transformed into SVG by pstoedit, layout by Inkscape. New version was created by a text editor.
Français : Courbe du flocon de neige de von Koch après 6 étapes (4,097 points) ; initialement créé avec Scilab, transformé en SVG avec pstoedit, mis en forme avec Inkscape. La nouvelle version a été faite avec un éditeur de texte. |
日期 | |
来源 | 自己的作品 |
作者 | Christophe Dang Ngoc Chan (cdang) |
授权 (二次使用本文件) |
GFDL |
其他版本 | Image:Von koch 1 etape.svg, Image:Von koch 2 etapes.svg, Image:Von koch 3 etapes.svg, Image:Von koch 4 etapes.svg, Image:Von koch 5 etapes.svg, Image:Von koch 6 etapes.svg, Image:VonKoch.svg |
SVG开发 InfoField |
Scilab source
This media was created with Scilab, a free open-source software. Here is a listing of the Scilab source used to create this file. |
English: English version by default.
Français : Version française, si les préférences de votre compte sont réglées (voir Special:Preferences).
Iterative source code
// ******************************
// * *
// * "Snowflake" von Koch curve *
// * *
// ******************************
clear;
clf;
// **************
// * constants *
// **************
n = 6;
// number of steps
// limited to 9 (262 145 points), otherwise the stacksize must be changed
// 6 steps (4 097 points) are enough for a good rendering
N = 4^n+1; // amount of points
sin_soixante = sqrt(3)/2; // sin(60°)
l = 1; // length of the initial line (arbitrary unit)
// ******************
// * initialisation *
// ******************
ycourbe = [zeros(1,N)];
ycourbe1 = ycourbe;
// *************
// * functions *
// *************
function [xx, yy] = etape(x, y)
// from a line [(x(1),y(1)) ; (x(2),y(2))]
// make the line [(xx(1),yy(1)) ; (xx(2),yy(2)) ; (xx(3),yy(3))]
// x and y are 2-cells tables, the ends of the basis line
// xx and yy are 3-cells tables
// the edges of the equilateral triangle
xu = (x(2)-x(1))/3;
yu = (y(2)-y(1))/3;
// third of the basis line vector
xv = 0.5*xu - sin_soixante*yu;
yv = sin_soixante*xu + 0.5*yu;
// vector turned by +60°
xx(1) = x(1)+xu; yy(1) = y(1)+yu;
xx(3) = x(2)-xu; yy(3) = y(2)-yu;
xx(2) = xx(1) + xv;
yy(2) = yy(1) + yv;
endfunction
function [xkoch, ykoch] = vonkoch(x, y, n)
// builds the curve
// initialisation
xkoch = x;
ykoch = y;
xkoch1 = x;
ykoch1 = y;
for i=1:n
jmax = 4^(i-1);
// number of lines at the beginning of the step i
for j=1:jmax/2+1
// we work with two points which indices are j and j+1 (line #j)
// thanks t the symmetry, we work with a half curve
decalage = (j-1)*4;
// the new points shift the next points by this offset
x_init = xkoch(j:j+1);
y_init = ykoch(j:j+1);
// line #j
[x_trans, y_trans] = etape(x_init,y_init);
// transformed line
xkoch1(decalage+1) = x_init(1); xkoch1(decalage+5) = x_init(2);
ykoch1(decalage+1) = y_init(1); ykoch1(decalage+5) = y_init(2);
for k=1:3
xkoch1(k+decalage+1) = x_trans(k);
ykoch1(k+decalage+1) = y_trans(k);
// values put in the global vector
end
end
xkoch = xkoch1; ykoch = ykoch1;
end
for i=1:4^n
ykoch(N-i+1) = ykoch(i);
xkoch(N-i+1) = l-xkoch(i);
// 2nd half-curve
end
endfunction
// ****************
// * main program *
// ****************
xcourbe(2) = l;
[xcourbe,ycourbe] = vonkoch(xcourbe,ycourbe,n);
// drawing the curve
xpoly(xcourbe,ycourbe)
isoview(0,l,0,l*sin_soixante/3)
The following code can be added to directly generate the file (the SVG export was not implemented at the time the file was created).
// saving the file
name = "von_koch_"+string(n)+"_steps.svg";
xs2svg(0, name)
Recursive source code
The code is more compact but the execution is slower, and does not generate the table of values.
//============================================================================
// name: von_koch.sce
// author: Christophe Dang Ngoc Chan
// date of creation: 2012-10-23
// dates of modification:
// 2013-07-08: quotes ' -> "
// 2013-07-2: vectorisation of the calculations
//----------------------------------------------------------------------------
// version of Scilab: 5.3.1
// required Atoms modules: aucun
//----------------------------------------------------------------------------
// Objective: draws the von Koch's "snowflake"
// Inputs: none (parameters are hard coded)
// Outputs: graphical window with a curve; SVG file
//============================================================================
clear;
clf;
// *************
// * constants *
// **************
n = 6;
// number of steps
// limited to 9 (262 145 points), otherwise the stacksize must be changed
// 6 steps (4 097 points) are enough for a good rendering
sin_soixante = sqrt(3)/2; // sin(60°)
l = 1;
// length of the initial line (arbitrary unit)
// ******************
// * initialisation *
// ******************
// *************
// * functions *
// *************
function [] = vonkoch(A, B, i)
u = (B - A)/3 ; // third of the AB vector
v = [0.5*u(1) - sin_soixante*u(2) ; sin_soixante*u(1) + 0.5*u(2)] ;
// vector turned by +60°
C = A + u ;
D = C + v ;
E = B - u ;
// points of the line
if i == 1 then
// drawing the smallest segments
x = [A(1) ; C(1) ; D(1) ; E(1) ; B(1) ];
y = [A(2) ; C(2) ; D(2) ; E(2) ; B(2) ];
xpoly(x, y, "lines")
else
j = i - 1 ;
vonkoch(A, C, j);
vonkoch(C, D, j);
vonkoch(D, E, j);
vonkoch(E, B, j);
// recursive call
end
endfunction
// ****************
// * main program *
// ****************
beginning = [0;0] ;
ending = [l;0] ;
vonkoch(beginning, ending, n)
isoview(0,l,0,sin_soixante*l)
// Saving the file
name = "von_koch_"+string(n)+"_steps.svg" ;
xs2svg(0, name)
许可协议
我,本作品著作权人,特此采用以下许可协议发表本作品:
已授权您依据自由软件基金会发行的无固定段落及封面封底文字(Invariant Sections, Front-Cover Texts, and Back-Cover Texts)的GNU自由文件许可协议1.2版或任意后续版本的条款,复制、传播和/或修改本文件。该协议的副本请见“GNU Free Documentation License”。http://www.gnu.org/copyleft/fdl.htmlGFDLGNU Free Documentation Licensetruetrue |
本文件采用知识共享署名-相同方式共享 3.0 未本地化版本许可协议授权。 | ||
| ||
本许可协议标签作为GFDL许可协议更新的组成部分被添加至本文件。http://creativecommons.org/licenses/by-sa/3.0/CC BY-SA 3.0Creative Commons Attribution-Share Alike 3.0truetrue |
您可以选择您需要的许可协议。
此文件中描述的项目
描繪內容
29 6 2006
文件历史
点击某个日期/时间查看对应时刻的文件。
日期/时间 | 缩略图 | 大小 | 用户 | 备注 | |
---|---|---|---|---|---|
当前 | 2018年2月21日 (三) 11:22 | 600 × 174(2 KB) | Cdang | even values and indentations | |
2007年5月19日 (六) 21:48 | 621 × 180(1 KB) | Fibonacci | Remade from scratch with simpler code. | ||
2006年6月29日 (四) 14:52 | 309 × 90(90 KB) | Cdang | in plain SVG (better behaviour) | ||
2006年6月29日 (四) 13:06 | 309 × 90(96 KB) | Cdang | {{Information |Description= {{en|von Koch snow flake curve after 6 steps; created with Scilab, transformed into SVG by pstoedit, layout by Inkscape}} {{fr|Courbe du flocon de neige de von Koch après 6 étapes ; créé avec Scilab, transformé en SVG avec |
文件用途
以下2个页面使用本文件:
全域文件用途
以下其他wiki使用此文件:
- ar.wikipedia.org上的用途
- ca.wikipedia.org上的用途
- es.wikipedia.org上的用途
- eu.wikipedia.org上的用途
- fr.wikipedia.org上的用途
- fr.wikibooks.org上的用途
- hr.wikipedia.org上的用途
- ht.wikipedia.org上的用途
- kn.wikipedia.org上的用途
- lo.wikipedia.org上的用途
- mn.wikipedia.org上的用途
- nl.wikipedia.org上的用途
- sh.wikipedia.org上的用途
- ta.wikipedia.org上的用途
- tcy.wikipedia.org上的用途
- vo.wikipedia.org上的用途
- zh.wikiversity.org上的用途
元数据
此文件中包含有扩展的信息。这些信息可能是由数码相机或扫描仪在创建或数字化过程中所添加。
如果此文件的源文件已经被修改,一些信息在修改后的文件中将不能完全反映出来。
宽度 | 600px |
---|---|
高度 | 174px |