I have been trying to draw equilateral triangles on the sides of a larger triangle. The first triangle is drawn by a separate method setting points A, B and C. So far I have just started with two sides, I am able to find the first two points of the smaller triangles, but I am unable to determine the correct formula for the third. I have tried refreshing my memory of trigonometry but I am at an impasse.
float a =0;
Point p = new Point(pnlDisplay.Width / 2 - (pnlDisplay.Width / 2) /3, 200);
Triangle t = new Triangle(p, pnlDisplay.Width / 3, 0);
drawEqTriangle(e, t);
Point p1 = new Point();
Point p2 = new Point();
Point p3 = new Point();
p1.X = Convert.ToInt32(A.X + t.size / 3);
p1.Y = Convert.ToInt32(A.Y);
p2.X = Convert.ToInt32(A.X + (t.size - t.size / 3));
p2.Y = Convert.ToInt32(A.Y);
//////////////////////////////
p3.X = Convert.ToInt32((A.X - t.size / 3) * Math.Sin(a));
p3.Y = Convert.ToInt32((A.Y - t.size / 3) * Math.Cos(a));
drawTriangle(e, p1, p2, p3);
p1.X = Convert.ToInt32((B.X - t.size / 3 * Math.Cos(t.angle + Math.PI / 3)));
p1.Y = Convert.ToInt32((B.Y + t.size / 3 * Math.Sin(t.angle+ Math.PI / 3)));
p2.X = Convert.ToInt32((B.X - (t.size - t.size / 3) * Math.Cos(t.angle + Math.PI / 3)));
p2.Y = Convert.ToInt32((B.Y + (t.size - t.size / 3) * Math.Sin(t.angle + Math.PI / 3)));
//////////////////////////////
p3.X = Convert.ToInt32((B.X - t.size / 3) * Math.Cos(a));
p3.Y = Convert.ToInt32((B.Y - t.size / 3) * Math.Tan(a));
drawTriangle(e, p1, p2, p3);
This may be a question for the math subsection, but I thought I would try here first. What I need is the formula for p3.X and p3.Y
Any help would be greatly appreciated.
EDIT: changing "a" to float a = Convert.ToSingle( 60 * Math.PI / 180);
Let's build universal formulas for any triangle orientation (note that it is worth to use A[] array for big triangle instead of explicit A,B,C vertices)