MCPcopy Create free account
hub / github.com/PyTTaMaster/PyTTa / _triangulate_curve

Function _triangulate_curve

pytta/_plot.py:1410–1430  ·  view source on GitHub ↗

Creates triangles along the curve points

(x, y, z, Pmin)

Source from the content-addressed store, hash-verified

1408
1409
1410def _triangulate_curve(x, y, z, Pmin):
1411 """
1412 Creates triangles along the curve points
1413 """
1414
1415 if len(x) != len(y) != len(z):
1416 raise ValueError("The lists x, y, z, must have the same length")
1417 n = len(x)
1418 if n % 2:
1419 raise ValueError("The length of lists x, y, z must be an even number")
1420 pts3d = np.vstack((x, y, z)).T
1421 pts3dp = np.array([[x[2 * k + 1], y[2 * k + 1], Pmin] for k in range(1, n // 2 - 1)])
1422 pts3d = np.vstack((pts3d, pts3dp))
1423
1424 # Triangulate the histogram bars:
1425 tri = [[0, 1, 2], [0, 2, n]]
1426 for k, i in zip(list(range(n, n - 3 + n // 2)), list(range(3, n - 4, 2))):
1427 tri.extend([[k, i, i + 1], [k, i + 1, k + 1]])
1428 tri.extend([[n - 3 + n // 2, n - 3, n - 2], [n - 3 + n // 2, n - 2, n - 1]])
1429
1430 return pts3d, np.array(tri)

Callers 1

waterfallFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected