Hexagonal Grid
1
//Hexagon Points Grid
2
s = 1;
3
a = s/(2*Math.Tan(30));
4
p1 = Point.ByCoordinates((0..#15..s*3)<1>,(0..#25..a*2)<2>);
5
p2 = List.Flatten(p1<1>.Translate([0,s*1.5]<2>,[0,a]<2>,0),1);
6
p3 = Polygon.RegularPolygon(Circle.ByCenterPointRadius(p2,s),6).Points;
7
d1 = (15*s*3)/((Math.Pow(p3.DistanceTo(Point.ByCoordinates(15*s*3/2,25*a*2/2)),0.75))+0.2);
8
p4 = Polygon.ByPoints(p3.Translate(Vector.ZAxis(),-d1+35));
Copied!
1
//Hexagon Points Grid
2
s = 10;
3
a = s/(2*Math.Tan(30));
4
p1 = Point.ByCoordinates((0..#15..s*3)<1>,(0..#25..a*2)<2>);
5
p2 = List.Flatten(p1<1>.Translate([0,s*1.5]<2>,[0,a]<2>,0),1);
6
p3 = Polygon.RegularPolygon(Circle.ByCenterPointRadius(p2,s),6);
Copied!
1
p4 = p3.Points;
2
3
//Attractor 1
4
v1 = Vector.ByTwoPoints(p3,a1);
5
v2 = v1.Scale(2/Math.Pow(v1.Length,0.25));
6
p5 = p4.Translate(v2);
7
8
//Attractor 2
9
v3 = Vector.ByTwoPoints(p4,a2);
10
v4 = v3.Scale(2/Math.Pow(v3.Length,0.25));
11
p6 = p5.Translate(v4);
Copied!

Hexagonal Grid on Surface

1
//Square Dimensions
2
wdt1 = 5000;
3
4
uDv1 = 15;
5
vDv1 = 20;
6
7
//Surface
8
srf1 = Surface.ByPatch(Rectangle.ByWidthLength(wdt1,wdt1));
9
rem1 = Math.DivRem(uDv1,3);
10
uDv2 = rem1==2?uDv1+1:uDv1+2;
11
uDv3 = rem1==3?uDv1:uDv2;
12
pt01 = srf1.PointAtParameter((0..1..#uDv3)<1>,(0..1..#vDv1)<2>);
13
pt02 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,-2),2,1);
14
pt03 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,-1),2,1);
15
pt04 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,-3),2,0);
16
pt05 = List.TakeEveryNthItem(List.TakeEveryNthItem(pt01<1>,4,0),2,0);
17
18
//Polygons
19
pt11 = [List.DropItems(pt02,-1),
20
List.DropItems(pt03,-1),pt05,
21
List.DropItems(pt03,1),
22
List.DropItems(pt02,1),pt04];
23
pt12 = List.Transpose(List.Transpose(pt11)<1>);
24
25
pt13 = [List.DropItems(List.DropItems(pt05<1>,-1),-1),
26
List.DropItems(List.DropItems(pt04<1>,1),-1),
27
List.DropItems(List.DropItems(List.DropItems(pt02<1>,1),1),-1),
28
List.DropItems(List.DropItems(pt04<1>,1),1),
29
List.DropItems(List.DropItems(pt05<1>,-1),1),
30
List.DropItems(List.DropItems(List.DropItems(pt03<1>,-1),1),-1)];
31
pt14 = List.Transpose(List.Transpose(pt13)<1>);
32
33
pg11 = Polygon.ByPoints([pt12,pt14]);];
Copied!
1
//Surface
2
srf1 = Surface.ByRevolve(NurbsCurve.ByPoints(Point.ByCoordinates
3
([20,18,18,22,22],0,[0,2,5,10,15])),Point.Origin(),Vector.ZAxis(),0,-180);
4
5
uDv1 = 25;
6
vDv1 = 52;
Copied!
hexagon_on_surface.dyn
29KB
Text
Copy link
Contents