Testing Waters
Search
K

# Koch Star

Pattern based on Koch curve
T-Spine visualization of Koch curve structure
def k1 (p:var[]..[])
{
v1 = Vector.ByTwoPoints(p[0],p[1]).Normalized();
d1 = p[0].DistanceTo(p[1]);
p1 = p[0].Translate(v1,d1/3);
v2 = v1.Rotate(Vector.ZAxis(),60);
p2 = p1.Translate(v2,d1/3);
p3 = p1.Translate(v1,d1/3);
return [p[0],p1,p2,p3,p[1]];
};
With Loops
def k2 (pts:var[]..[])
{
p1 = List.DropItems(List.Sublists(pts,0..1,1),-1);
p2 = k1(p1<1>);
p3 = Point.PruneDuplicates(List.Flatten(p2,-1),0.1);
};
def k3 (pt:var[]..[],it:int)
{
a = [Imperative]
{
c = 0;
b = [];
while (c < it)
{
b = k2(pt);
pt = b;
c = c + 1;
}
return b;
}
return a;
};
With Recursion
def k2(pts:var[]..[],n:int[]..[])
{
a = [Imperative]
{
if (List.Count(pts)>=Math.Pow(5,n))
return pts;
else
{
b = [Associative]
{
p1 = List.DropItems(List.Sublists(pts,0..1,1),-1);
p2 = k1(p1<1>);
p3 = List.Flatten(p2,-1);
return p3;
}
return Point.PruneDuplicates(k2(b,n),0.1);
}
}
b = List.Clean(List.Flatten(a,-1),false);
};
Visualization with T-Splines
// T Spline Visualization
[50,35,25,5])<1>.PointAtParameter((1..0..#4)<2>));
p002 = k2(p001<1>,2).Translate(Vector.ZAxis(),[0,10,15,60]);
pc01 = PolyCurve.ByPoints(List.Transpose(p002));
pc02 = PolyCurve.ByPoints(pc01.PointAtParameter((0..1..#10)<1>));
ts01 = TSplineSurface.BuildPipes(List.Flatten(pc01.Explode(),-1),
1.5,0.1,3,true,false,0,0,1,0.3,1,1,true);
ts02 = TSplineSurface.BuildPipes(pc02.Explode(),2..0.2..#10,
2..0.2..#10,3,true,false,0,0,1,0.3,1,1,true);
ts03 = TSplineSurface.ByCombinedTSplineSurfaces
(List.Flatten([ts01,ts02],-1)).Translate(150,0,0);
koch.stl
98MB
Binary
STL file