5
// janzarsky <${AuthorEmail}>
7
// Copyright (c) 2012 janzarsky
9
// This program is free software: you can redistribute it and/or modify
10
// it under the terms of the GNU General Public License as published by
11
// the Free Software Foundation, either version 3 of the License, or
12
// (at your option) any later version.
14
// This program is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, see <http://www.gnu.org/licenses/>.
22
using System.Collections.Generic;
24
namespace TreeGenerator {
25
class Polyhedron : IMatrix, IComposite<Polyhedron> {
27
Matrix matrix = Matrix.Empty;
30
List<Polyhedron> children = new List<Polyhedron>();
32
public Polyhedron(double perimeter, int quality, Matrix generalMatrix) {
33
this.perimeter = perimeter;
34
this.quality = quality;
35
this.generalMatrix = generalMatrix;
38
public void AddChild(double perimeter, int quality) {
39
children.Add(new Polyhedron(perimeter, quality, generalMatrix));
42
public Circle CreateCircle(Circle circle) {
43
Matrix finalMatrix = Matrix.FromMatrixes(matrix, generalMatrix);
45
circle.AddChild(new Circle(perimeter/2, quality, finalMatrix));
47
for (int i = 0; i < children.Count; i++)
48
children[i].CreateCircle(circle.Children[circle.Children.Count - 1]);
53
public List<Polyhedron> Children {
54
get { return children; }
57
public void ApplyMatrix(Matrix matrix) {
58
this.matrix.Multiply(matrix);
60
foreach (Polyhedron child in children)
61
child.ApplyMatrix(matrix);
b'\\ No newline at end of file'