我正在尝试制作三叶草晶体以供以后制造,并使用纳斯卡设计工具来完成它。
如何放置梯形,使梯形的边与圆平行,并且始终位于尖角的末端。
import nazca as nd
import numpy as np
# Define parameters
a = 500
semib = 0.255 * a
semia = semib * 0.75
shift = 0.22 * a
thickness = 0.65 * a
f = 2 * semia / np.sqrt(3)
r = semia
with nd.Cell(name="shamrock") as sham:
# Create circles for the shamrock pattern
circ1 = nd.geometries.circle(radius=semia, N=100)
circ2 = nd.geometries.circle(radius=semia, N=100)
circ3 = nd.geometries.circle(radius=semia, N=100)
# Create Polygon objects for circles
circ1_polygon = nd.Polygon(layer=56, points=circ1)
circ2_polygon = nd.Polygon(layer=56, points=circ2)
circ3_polygon = nd.Polygon(layer=56, points=circ3)
# Place circles for the shamrock pattern using put
circ1_polygon.put(0, shift)
circ2_polygon.put(-shift * 0.5 * np.sqrt(3), -shift * 0.5)
circ3_polygon.put(shift * 0.5 * np.sqrt(3), -shift * 0.5)
# Identify sharp corners
sharp_corner1 = ((-shift * 0.5 * np.sqrt(3)) / 2, (shift + (-shift * 0.5)) / 2)
sharp_corner2 = ((0 + (shift * 0.5 * np.sqrt(3))) / 2, (shift + (-shift * 0.5)) / 2)
sharp_corner3 = ((-shift * 0.5 * np.sqrt(3) + (shift * 0.5 * np.sqrt(3))) / 2, (-shift * 0.5 + (-shift * 0.5)) / 2)
semicircle_radius = f-r
# Create trapezoid using the trapezoid function
trapezoid_shape = nd.geometries.trapezoid(length=50, height=160, angle1=132, angle2=132, position=1)
# Create Polygon object for trapezoid
trapezoid_polygon = nd.Polygon(layer=56, points=trapezoid_shape)
# Place trapezoid at the sharp corners
trapezoid_polygon.put(25,75,180)
nd.export_plt(sham)
这是图片。
理想情况下,如果有这样的边角平滑的东西就好了。但我想在上面放一个梯形来平滑更尖的角。
这可以通过增大和缩小纳斯卡中的多边形来完成:
import nazca as nd
import numpy as np
# Define parameters
a = 500
semib = 0.255 * a
semia = semib * 0.75
shift = 0.22 * a
thickness = 0.65 * a
f = 2 * semia / np.sqrt(3)
r = semia
with nd.Cell(name="shamrock") as sham:
# Create circles for the shamrock pattern
circ1 = nd.geometries.circle(radius=semia, N=100)
circ2 = [(x - semia, y - np.sqrt(3) * semia) for x, y in circ1]
circ3 = [(x + semia, y - np.sqrt(3) * semia) for x, y in circ1]
# grow and shrink 20%
pols = nd.grow_polygons([circ1, circ2, circ3], 0.2 * semia)
pols = nd.grow_polygons(pols, -0.2 * semia)
for p in pols:
nd.Polygon(layer=56, points=p).put()
nd.export_plt(sham)