Skip to content

Commit 5eb575b

Browse files
committed
add plot functionality
1 parent a25eabd commit 5eb575b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

congruent.py

+16-4
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,27 @@
4444

4545
print('Congurent Triangles are',hl.congurent)
4646

47-
#[[1,1], [2,1], [2,2], [1,2]]
47+
"""
48+
coord = [[1,1], [2,1], [2,2], [1,2]]
49+
coord.append(coord[0]) #repeat the first point to create a 'closed loop'
50+
51+
xs, ys = zip(*coord) #create lists of x and y values
52+
53+
plt.figure()
54+
plt.plot(xs,ys)
55+
"""
4856
for u in hl.congurent:
49-
a0 = [[u[0].p1.x,u[0].p1.y],[u[0].p2.x,u[0].p2.y],[u[0].p3.x,u[0].p3.y]]
50-
a1 = [[u[1].p1.x,u[1].p1.y],[u[1].p2.x,u[1].p2.y],[u[1].p3.x,u[1].p3.y]]
57+
a0 = [[u[0].p1.x,u[0].p1.y],[u[0].p2.x,u[0].p2.y],[u[0].p3.x,u[0].p3.y],[u[0].p1.x,u[0].p1.y]]
58+
a1 = [[u[1].p1.x,u[1].p1.y],[u[1].p2.x,u[1].p2.y],[u[1].p3.x,u[1].p3.y],[u[1].p1.x,u[1].p1.y]]
5159
if a0 not in plot:
5260
plot.append(a0)
5361
if a1 not in plot:
5462
plot.append(a1)
55-
break
5663

64+
for coord in plot:
65+
xs, ys = zip(*coord) #create lists of x and y values
66+
plt.figure('triangles')
67+
plt.plot(xs,ys)
68+
5769
print('-----------',plot)
5870

0 commit comments

Comments
 (0)