Geodesic Sphere
Geodesic Sphere based on an Icosahedron
Last updated
Geodesic Sphere based on an Icosahedron
Last updated
// Radius
rad = 12;
// Division Depth
d = 9;
// Icosahedron
p = (1+Math.Sqrt(5))/2;
a = Point.ByCoordinates([0,0,0,0,p,-p,-p,p,1,-1,-1,1],[1,-1,-1,1,0,0,0,0,p,p,-p,-p],[p,p,-p,-p,1,1,-1,-1,0,0,0,0]);
b = [[a[0],a[8],a[9]],[a[0],a[9],a[5]],[a[0],a[5],a[1]],[a[0],a[1],a[4]],[a[0],a[4],a[8]],
[a[1],a[5],a[10]],[a[1],a[10],a[11]],[a[1],a[11],a[4]],[a[2],a[3],a[7]],[a[2],a[7],a[11]],
[a[2],a[11],a[10]],[a[2],a[10],a[6]],[a[2],a[6],a[3]],[a[3],a[6],a[9]],[a[3],a[9],a[8]],
[a[3],a[8],a[7]],[a[4],a[11],a[7]],[a[4],a[7],a[8]],[a[5],a[9],a[6]],[a[5],a[6],a[10]]];
tri = Surface.ByPerimeterPoints(b);
// Sub dividing equilateral faces
// Edges of equilateral surface
crv1 = tri.PerimeterCurves();
len1 = List.GetItemAtIndex(crv1<1>,0).Length;
n = d<1?1:d;
len2 = len1/n;
// Vertices of equilateral surface
pnt1 = List.GetItemAtIndex(crv1<1>,0).StartPoint;
pnt2 = List.GetItemAtIndex(crv1<1>,1).StartPoint;
pnt3 = List.GetItemAtIndex(crv1<1>,2).StartPoint;
dir1 = Vector.ByTwoPoints(pnt1,pnt2);
dir2 = Vector.ByTwoPoints(pnt1,pnt3);
dir3 = Vector.ByTwoPoints(pnt2,pnt3);
// Sub triangle 1
pnt4 = pnt1.Translate(dir1,len2);
pnt5 = pnt1.Translate(dir2,len2);
sub1 = Polygon.ByPoints(Transpose([pnt1,pnt4,pnt5]));
// Repeating sub triangle
n2 = (0..(n-1))*len2<1>;
sub2 = sub1.Translate(dir1,n2);
n3 = List.TakeItems(n2<1>,1..n);
sub3 = sub2.Translate(dir3,n3);
// Sub triangle 2
pnt6 = n<2?pnt1:pnt4.Translate(dir2,len2);
sub4 = Polygon.ByPoints(Transpose([pnt4,pnt5,pnt6]));
n4 = (0..(n-2))*len2<1>;
sub5 = sub4.Translate(dir1,n4);
n5 = List.TakeItems(n4<1>,1..n);
sub6 = sub5.Translate(dir3,n5);
sub21 = List.Flatten(List.TakeItems([sub3,sub6],n),-1);
plPnt1 = List.Flatten(sub21).Points;
plDir1 = Vector.ByTwoPoints(Point.Origin(),plPnt1);
sph = Sphere.ByCenterPointRadius(Point.Origin(),rad);
plPnt21 = List.Flatten(sph.ProjectInputOnto(plPnt1,plDir1)<1>,-1);
pl1 = Polygon.ByPoints(plPnt21);
sr1 = pl1.Patch();
sr2 = GeometryColor.ByGeometryColor(List.Transpose(List.Chop(sr1,4)),
Color.ByARGB(255,[115,105,25,200],[200,100,56,169],26));