I took a look. There is a regularity in your triangle construction. I use a pseudo code to represent two trajectories, and set the coordinates of each point as:
dot_nt = (x,y,z) -sharp nn in (1,2);tn in [0,n]
then for track 1, it can be formed:
[dot_10,dot_11,dot_12,...]
for track 2, it can be formed:
[dot_20,dot_21,dot_22,...]
then, you can see a
[dot_10,dot_20,dot_11],[dot_11,dot_21,dot_12],[dot_12,dot_22,dot_13],...
such a regular data, and then according to this law, you can use the program to form a triangle. If you think the train of thought is right, you can try to achieve it. I think this should be what it looks like
.
two points: the triangle is a, b take turns; the trajectory sequence may not be equal in length.
def find_triangle(a, b):
-sharp
la, lb = len(a), len(b)
if la > lb:
a, b = b, a
la, lb = lb, la
-sharp ab
triangles = []
for i in range(la - 1):
triangles.append((b[i], a[i], b[i + 1]))
triangles.append((a[i], b[i + 1], a[i + 1]))
-sharp
more = b[la - 1:]
for j in range(len(more) - 1):
triangles.append((more[j], a[la - 1], more[j + 1]))
return triangles
>>> S1 = ['a1', 'a2', 'a3']
>>> S2 = ['b1', 'b2', 'b3', 'b4', 'b5']
>>> print(find_triangle(S1, S2))
[('b1', 'a1', 'b2'), ('a1', 'b2', 'a2'), ('b2', 'a2', 'b3'), ('a2', 'b3', 'a3'), ('b3', 'a3', 'b4'), ('b4', 'a3', 'b5')]
>>> print(find_triangle(S2, S1))
[('b1', 'a1', 'b2'), ('a1', 'b2', 'a2'), ('b2', 'a2', 'b3'), ('a2', 'b3', 'a3'), ('b3', 'a3', 'b4'), ('b4', 'a3', 'b5')]
Total area = area of all triangles with black background + area of all triangles with red background
focus on three points of triangles
Black dots are numbered as b0~b4
Red dots are numbered as r0~r4
Triangles with black bottoms are b0b1r0Magne. B 3 b 4 r 3
the three points of the red background triangle are r 0 r 1 r 1 Magi. R3, R4, R4
come up with the rest and then continue to think about it
.
part of the code can be written like this
class Point:
__slots__=('x','y','z')
def __init__(self,x,y,z):
self.x,self.y,self.z=x,y,z
red_point,black_point=list (range (4)), list (range (4))
blacktria= [(for iMagne1) for iLigue j in zip (black_point [: 4], red_point [: 4])
redtria= [(jGram1 for iMagn1) for iLING j in zip (black_point [: 4], red_point [: 4])
print (blacktria,'n',redtria)
The contents of
blacktria and redtria are as follows:
[(0,1,0), (1,2,1), (2,3,2), (3,4,3)]
[(0,1,1), (1,2,2), (2,3,3), (3,4,4)]