added Algorithms/SierpinskiTriangle.cs
This commit is contained in:
1 parent
6acd8c8ff1
commit
a832521bda
7 files changed
+137
-4
No files matched your search
@@ -0,0 +1,22 @@
|
||||
namespace Algorithms;
|
||||
|
||||
public class SierpinskiTriangle{
|
||||
private readonly Random random;
|
||||
|
||||
public SierpinskiTriangle(Random random){
|
||||
this.random = random;
|
||||
}
|
||||
|
||||
public List<Point> GenerateRandomPath(Point point, int length){
|
||||
List<Point> path = new List<Point>();
|
||||
Triangle triangle = Triangle.Equilateral(10);
|
||||
for(int i = 0; i < length; i++){
|
||||
path.Add(point);
|
||||
point = point.MidPointOf(triangle.RandomSummit(random));
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user