Geodesic Sphere
Geodesic Sphere based on an Icosahedron
1
// Radius
2
rad = 12;
3
4
// Division Depth
5
d = 9;
6
7
// Icosahedron
8
p = (1+Math.Sqrt(5))/2;
9
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]);
10
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]],
11
[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]],
12
[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]],
13
[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]]];
14
tri = Surface.ByPerimeterPoints(b);
15
16
// Sub dividing equilateral faces
17
// Edges of equilateral surface
18
crv1 = tri.PerimeterCurves();
19
len1 = List.GetItemAtIndex(crv1<1>,0).Length;
20
n = d<1?1:d;
21
len2 = len1/n;
22
23
// Vertices of equilateral surface
24
pnt1 = List.GetItemAtIndex(crv1<1>,0).StartPoint;
25
pnt2 = List.GetItemAtIndex(crv1<1>,1).StartPoint;
26
pnt3 = List.GetItemAtIndex(crv1<1>,2).StartPoint;
27
28
dir1 = Vector.ByTwoPoints(pnt1,pnt2);
29
dir2 = Vector.ByTwoPoints(pnt1,pnt3);
30
dir3 = Vector.ByTwoPoints(pnt2,pnt3);
31
32
// Sub triangle 1
33
pnt4 = pnt1.Translate(dir1,len2);
34
pnt5 = pnt1.Translate(dir2,len2);
35
sub1 = Polygon.ByPoints(Transpose([pnt1,pnt4,pnt5]));
36
37
// Repeating sub triangle
38
n2 = (0..(n-1))*len2<1>;
39
sub2 = sub1.Translate(dir1,n2);
40
n3 = List.TakeItems(n2<1>,1..n);
41
sub3 = sub2.Translate(dir3,n3);
42
43
// Sub triangle 2
44
pnt6 = n<2?pnt1:pnt4.Translate(dir2,len2);
45
sub4 = Polygon.ByPoints(Transpose([pnt4,pnt5,pnt6]));
46
n4 = (0..(n-2))*len2<1>;
47
sub5 = sub4.Translate(dir1,n4);
48
n5 = List.TakeItems(n4<1>,1..n);
49
sub6 = sub5.Translate(dir3,n5);
50
51
sub21 = List.Flatten(List.TakeItems([sub3,sub6],n),-1);
52
53
plPnt1 = List.Flatten(sub21).Points;
54
plDir1 = Vector.ByTwoPoints(Point.Origin(),plPnt1);
55
56
sph = Sphere.ByCenterPointRadius(Point.Origin(),rad);
57
plPnt21 = List.Flatten(sph.ProjectInputOnto(plPnt1,plDir1)<1>,-1);
58
pl1 = Polygon.ByPoints(plPnt21);
59
sr1 = pl1.Patch();
60
61
sr2 = GeometryColor.ByGeometryColor(List.Transpose(List.Chop(sr1,4)),
62
Color.ByARGB(255,[115,105,25,200],[200,100,56,169],26));
Copied!
Last modified 3mo ago
Copy link