def wet_circles(A, B, thetaA, thetaB):
"""Generates a mesh that wets the surface of circles A and B.
Parameters
-------------
A,B : Circle
theta : list
the number of radians that the wet covers and number of the points on
the surface range
"""
vector = B.center - A.center
if vector.x > 0:
angleA = np.arctan(vector.y/vector.x)
angleB = np.pi + angleA
else:
angleB = np.arctan(vector.y/vector.x)
angleA = np.pi + angleB
# print(vector)
rA = A.radius
rB = B.radius
points = []
for t in ((np.arange(0, thetaA[1])/(thetaA[1]-1) - 0.5)
* thetaA[0] + angleA):
x = rA*np.cos(t) + A.center.x
y = rA*np.sin(t) + A.center.y
points.append([x, y])
mid = len(points)
for t in ((np.arange(0, thetaB[1])/(thetaB[1]-1) - 0.5)
* thetaB[0] + angleB):
x = rB*np.cos(t) + B.center.x
y = rB*np.sin(t) + B.center.y
points.append([x, y])
points = np.array(points)
# Triangulate the polygon
tri = Delaunay(points)
# Remove extra triangles
# print(tri.simplices)
mask = np.sum(tri.simplices < mid, 1)
mask = np.logical_and(mask < 3, mask > 0)
tri.simplices = tri.simplices[mask, :]
# print(tri.simplices)
m = Mesh()
for t in tri.simplices:
m.append(Triangle(Point([points[t[0], 0], points[t[0], 1]]),
Point([points[t[1], 0], points[t[1], 1]]),
Point([points[t[2], 0], points[t[2], 1]])))
return m
评论列表
文章目录