Open dhermes opened 6 years ago
CASE2a = np.asfortranarray(
[
[
-0.8214285714285716,
-0.8299520788750556,
-0.8385565991179567,
-0.830357142857143,
-0.8389211567018355,
-0.8392857142857144,
],
[
-1.0,
-0.9912577228478906,
-0.982478186840489,
-1.0,
-0.9912390934202446,
-1.0,
],
]
)
CASE2b = np.asfortranarray(
[
[
-0.8158482142857143,
-0.8253348214285713,
-0.8348214285714286,
-0.8253348214285715,
-0.8348214285714285,
-0.8348214285714286,
],
[
-1.0055803571428572,
-0.9960937500000001,
-0.986607142857143,
-1.0055803571428577,
-0.9960937500000002,
-1.0055803571428572,
],
]
)
surface1 = bezier.Surface(CASE2a, degree=2)
surface2 = bezier.Surface(CASE2b, degree=2)
intersection, = surface1.intersect(surface2)
ax = surface1.plot(256)
surface2.plot(256, ax=ax)
intersection.plot(256, ax=ax)
ax.axis('scaled')
ax.figure.show()
CASE3a = np.asfortranarray(
[
[
-0.9282473773857585,
-0.9194403251518133,
-0.9107142857142857,
-0.919278299558978,
-0.910511753723242,
-0.910309221732198,
],
[
-0.9822918925640269,
-0.9911645757096599,
-1.0,
-0.9823105219916728,
-0.9911645757096597,
-0.9823291514193193,
],
]
)
CASE3b = np.asfortranarray(
[
[
-0.8917410714285715,
-0.9012276785714285,
-0.9107142857142858,
-0.9012276785714286,
-0.9107142857142858,
-0.9107142857142859,
],
[
-1.0055803571428572,
-0.9960937500000003,
-0.986607142857143,
-1.0055803571428572,
-0.9960937500000002,
-1.0055803571428572,
],
]
)
surface1 = bezier.Surface(CASE3a, degree=2)
surface2 = bezier.Surface(CASE3b, degree=2)
intersection, = surface1.intersect(surface2)
ax = surface1.plot(256)
surface2.plot(256, ax=ax)
intersection.plot(256, ax=ax)
ax.axis('scaled')
ax.figure.show()
CASE4a = np.asfortranarray(
[
[
-1.0,
-0.9912364210826126,
-0.9824398436629882,
-1.0,
-0.9912199218314941,
-1.0,
],
[
0.8214285714285713,
0.8301847323610781,
0.838975375392798,
0.8303571428571429,
0.8391305448392564,
0.8392857142857142,
],
]
)
CASE4b = np.asfortranarray(
[
[
-1.0055803571428572,
-0.9960937500000001,
-0.986607142857143,
-1.0055803571428577,
-0.9960937500000002,
-1.0055803571428572,
],
[
0.8158482142857142,
0.8253348214285714,
0.8348214285714285,
0.825334821428571,
0.8348214285714286,
0.8348214285714285,
],
]
)
surface1 = bezier.Surface(CASE4a, degree=2)
surface2 = bezier.Surface(CASE4b, degree=2)
intersection, = surface1.intersect(surface2)
ax = surface1.plot(256)
surface2.plot(256, ax=ax)
intersection.plot(256, ax=ax)
ax.axis('scaled')
ax.figure.show()
Here are 16 more cases:
It's worth noting, these were "detected" by approximating each surface by a polygon (by just evaluating at 64 points along each edge, i.e. 0, 1/64, ..., 63/64
) and then intersecting the polygons using Shapely
.
I tried to be careful to figure out what type of intersection there was (i.e. Polygon
vs. MultiPolygon
vs. LineString
etc.) but I'm fairly certain that accessing .area
will work in a consistent way:
s_vals = np.linspace(0, 1, 65)[:64]
evaluated1 = np.empty((2, 192), order='F')
index = 0
for edge in surface1.edges:
evaluated1[:, index:index + 64] = edge.evaluate_multi(s_vals)
index += 64
polygon1 = shapely.geometry.Polygon(evaluated1.T)
evaluated2 = np.empty((2, 192), order='F')
index = 0
for edge in surface2.edges:
evaluated2[:, index:index + 64] = edge.evaluate_multi(s_vals)
index += 64
polygon2 = shapely.geometry.Polygon(evaluated2.T)
intersection = polygon1.intersection(polygon2)
print(intersection.area)
These came up when I was randomly generating surfaces and intersecting them (and solving some PDEs along the way). There are (at least 4 cases).
Case 1