![]() |
Матрица статей Список статей Всячина Контакты | ||||||||||||
|
Деревья и ветки
program Vetka2; uses Graph, CRT; const min = 1; var gd, gm : Integer; procedure lineto1(x, y : Integer; l, u : real); begin Line(x, y, Round(x + l * cos(u)), Round(y - l * sin(u))); end; procedure Draw(x, y : Integer; l, u : real); begin if KeyPressed then exit; if l > min then begin lineto1(x, y, l, u); x := Round(x + l * cos(u)); y := Round(y - l * sin(u)); Draw(x, y, l*0.4, u - pi/4); Draw(x, y, l*0.4, u + pi/4); Draw(x, y, l*0.7, u); end; end; begin gd := Detect; InitGraph(gd, gm, 'c:\bp\bgi'); Draw(320, 460, 120, pi/2); ReadKey; CloseGraph; end. ... procedure Draw(x, y : Integer; l, u : real); begin if KeyPressed then exit; if l > min then begin lineto1(x, y, l, u); x := Round(x + l * cos(u)); y := Round(y - l * sin(u)); Draw(x, y, l*0.4, u - pi/4); Draw(x + Round(l*0.4*cos(u)), y - Round(l*0.4*sin(u)), l*0.4, u + pi/4); Draw(x, y, l*0.7, u); end; end; ... program Tree3; uses CRT, Graph; var gd, gm: Integer; procedure FrTree(x, y, l, u : Real; t : Integer); begin if t > 0 then begin l := l*0.5; Line(Round(x), Round(y), Round(x + l*cos(u)), Round(y - l*sin(u))); x := Round(x + l * cos(u)); y := Round(y - l * sin(u)); FrTree(x, y, l, u, t-1); FrTree(x, y, l, u+pi/4, t-1); FrTree(x, y, l, u-pi/4, t-1); end; end; begin gd:=Detect; InitGraph(gd, gm, 'c:\bp\bgi'); FrTree(320, 460, 350, pi/2, 6); FrTree(320, 460, 350, 3*pi/4, 6); FrTree(320, 460, 350, pi/4, 6); ReadKey; CloseGraph end. При написании последней программы использовался код, предоставленный Аслановым А. М.
Tree_1 {
0 0 0 0.50 0 0 0.05
0.42 -0.42 0.42 0.42 0 0.2 0.4
0.42 0.42 -0.42 0.42 0 0.2 0.4
0.1 0 0 0.1 0 0.2 0.15
}
Tree_2 {
0.195 -0.488 0.344 0.443 0.4431 0.2452 0.25
0.462 0.414 -0.252 0.361 0.2511 0.5692 0.25
-0.058 -0.07 0.423 -0.111 0.5976 0.0969 0.15
-0.035 0.07 -0.469 0.022 0.4884 0.5069 0.15
-0.637 0 0 0.501 0.8562 0.2513 0.2
}
Tree_3 {
0.28421 -0.35644 0.32632 0.44555 0.00625 0.56275 0.166
0.37895 0.38614 -0.27368 0.34653 -0.08171 0.54063 0.166
0.41053 0 0 0.55446 -0.02832 0.53347 0.166
-0.62105 0 0 0.43564 -0.09537 0.35772 0.166
-0.03158 -0.07921 0.55790 -0.08911 -0.00755 0.51196 0.166
-0.08421 0.08911 -0.55790 -0.05941 -0.17617 0.40587 0.166
}
Tree_4 {
0.05 0 0 0.4 -0.06 -0.47 0.02600
-0.05 0 0 -0.4 -0.06 -0.47 0.02640
0.03 -0.14 0 0.26 -0.16 -0.01 0.01030
-0.03 0.14 0 -0.26 -0.16 -0.01 0.01030
0.56 0.44 -0.37 0.51 0.3 0.15 0.59187
0.19 0.07 -0.01 0.15 -0.2 0.28 0.03854
-0.33 -0.34 -0.33 0.34 -0.54 0.39 0.29620
}
Tree_5 {
0.05 0 0 0.6 0 0 0.02800
0.05 0 0 -0.5 0 1 0.02326
0.45963 -0.32139 0.38567 0.38302 0 0.6 0.27907
0.46985 -0.15391 0.17101 0.42286 0 1.1 0.20930
0.43301 0.275 -0.25 0.47631 0 1 0.25581
0.42133 0.25712 -0.35353 0.30642 0 0.7 0.20465
}
Tree_6 {
0.45881 -0.22565 0.07268 0.60187 -0.00177 0.31948 0.31
0.34268 0.37561 -0.20337 0.54642 -0.02210 0.32976 0.20
0.13582 0.50273 -0.31347 0.13846 -0.02004 0.21706 0.16
0.25326 -0.48975 0.30798 0.34989 -0.00740 0.19810 0.23
0.06641 0 0 0.47942 -0.01492 -0.02422 0.10
}
Leaf {
0.14 0.01 0.00 0.51 -0.08 -1.31 0.06
0.43 0.52 -0.45 0.50 1.49 -0.75 0.37
0.45 -0.49 0.47 0.47 -1.62 -0.74 0.36
0.49 0.00 0.00 0.51 0.02 1.62 0.21
}
Fir_2 {
0.1000 0.0000 0.0000 0.1600 0.0 0.0 0.01
0.8500 0.0000 0.0000 0.8500 0.0 1.6 0.85
-0.1667 -0.2887 0.2887 -0.1667 0.0 1.6 0.07
-0.1667 0.2887 -0.2887 -0.1667 0.0 1.6 0.07
}
Fir {
0.024000 0.000000 0.000000 0.432000 -0.036000 -0.748000 0.011383
0.767883 0.014660 -0.013403 0.839872 -0.058041 1.703451 0.708329
-0.058172 0.359454 0.329910 0.063381 0.178422 2.002845 0.134255
0.078732 -0.370260 0.341029 0.085481 -0.077863 2.091658 0.146031
}
Second_plant {
0.340055 0.383769 0.078507 0.638699 0.2641 -0.742253 0.190775
0.340055 -0.383769 -0.078507 0.638699 -0.335438 -0.688348 0.190775
0.770000 0 0 0.742 -0.012 2.742 0.582676
0.074000 0 0 0.474 0.024 -0.538 0.035772
}
Twigs {
0.424242 -0.651515 -0.484848 -0.344697 3.442830 2.889184 0.622449
0.030303 -0.439394 -0.636364 -0.022727 -1.425239 6.437284 0.377551
}
Leaf_2 {
0.242424 0.640152 0.909091 -0.318182 4.597023 -5.567530 0.698795
-0.090909 0.556818 0.484848 0.155303 -0.971878 -5.600669 0.301205
}
Maple {
0.49 -0.01 0 0.62 0.25 0.02 0.316
0.27 -0.52 0.4 0.36 0 -0.56 0.316
0.18 0.73 -0.5 0.26 0.88 -0.08 0.316
0.04 0.01 -0.5 0 0.52 -0.32 0.052
}
Leaf_70 {
0.000000 0.243900 0.000000 0.305300 0.000000 0.000000 0.010000
0.724800 0.033700 -0.025300 0.742600 0.206000 0.253800 0.710544
0.158300 -0.129700 0.355000 0.367600 0.138300 0.175000 0.137386
0.338600 0.369400 0.222700 -0.075600 0.067900 0.082600 0.142169
}
Смотрите также: Ссылки:
|