Well, since the distances form a Pythagorean triple the choice was not that random. You are on the right track and reflection is a great idea, but you need to take it a step further.
Check that in the (imperfect) drawing below $\triangle RBM$, $\triangle AMQ$, $\triangle MPC$ are equilateral, since they each have two equal sides enclosing angles of $\frac{\pi}{3}$. Furthermore, $S_{\triangle ARM}=S_{\triangle QMC}=S_{\triangle MBP}$ each having sides of length 3,4,5 respectively (sometimes known as the Egyptian triangle as the ancient Egyptians are said to have known the method of constructing a right angle by marking 12 equal segments on the rope and tying it on the poles to form a triangle; all this long before the Pythagoras' theorem was conceived)
By construction the area of the entire polygon $ARBPCQ$ is $2S_{\triangle ABC}$
On the other hand
$$ARBPCQ= S_{\triangle AMQ}+S_{\triangle MPC}+S_{\triangle RBM}+3S_{\triangle ARM}\\=\frac{3^2\sqrt{3}}{4}+\frac{4^2\sqrt{3}}{4}+\frac{5^2\sqrt{3}}{4}+3\frac{1}{2}\cdot 3\cdot 4 = 18+\frac{25}{2}\sqrt{3}$$
Hence
$$S_{\triangle ABC}= 9+\frac{25\sqrt{3}}{4}$$
Ok, this answer is a bit lame but anyway.
To achieve what you are searching for you need just two functions
- A function that draw a triangle with a given corner point and a rotation and a radius lets call this one
drawTriangle
- A function that draws supsequent triangles
drawMoreTriangles
The problem I ran into when I wanted to create the second part (after getting pygame work again) was that you your triangle drawing function does not work with any rotation but just with a very specific one ($\frac{\pi}{6}$).
I noticed this after implementing part 2!
The Problem here is that your Point2D
class has really less functionality to work with what you need is a class like this:
class Point2D:
def __init__(self, x,y):
self.x = x
self.y = y
def __add__(self, obj):
""" This Function will translate a Point """
self.x = obj.x
self.y = obj.y
def rotate(self, arc):
""" This function will rotate by arc around (0,0) """
sa = math.sin(arc)
ca = math.cos(arc)
x = ca * self.x - sa * self.y
self.y = sa * self.x + ca * self.y
self.x = x
Now you can implement your triangle (part 1) really easy:
def drawTriangle(window, center, radius, rotation):
corner = Point2D(radius, 0)
pointlist = [None]
for i in range(3):
pointlist[i] = [int(corner.x+center.x), int(corner.y+center.y)]
if i == 2:
break
# Rotate the corner by 60 degrees
corner = corner.rotate(math.pi/3)
pygame.draw.polygon(window, color, pointlist, width)
Now you can also easily achieve (part 2), by using the above function for drawing triangles (if it works did not test yet) and using rotation and translation!
Gonna post a bit more if I've got more time!
Best Answer
As in the attached diagram, let $ABC$ be the original equilateral triangle and let $D$ be a point in $\triangle ABC$.
We let point $E$ be on the opposite side of $BC$ as $D$ such that $\triangle BDE$ is equilateral. Then $BD=BE$, $BA=BC$ and $\angle DBA=\angle EBC=60^{\circ}-\angle DBC$. And therefore $\triangle DBA$ and $\triangle EBC$ are congruent. This implies that $EC=DA$ and since $DE=BD$, we now have $\triangle CDE$ as the triangle we want.
Let $\angle ADB=x$ and $\angle BDC=y$. Then $\angle EDC=y-60^{\circ}$, $\angle DEC=x-60^{\circ}$ and $\angle DCE=300^{\circ}-x-y$ are our desired angles.