# How to calculate missing point of triangle?

I am about to develop a special animation where I want to rotate a triangle (given a specific width angle) around a circle (given a specific radius) given a specific rotationAngle.

This is how I can calculate the 2 coordinates x1 / x2 that stands for the base of the triangle (the two coordinates that are hitting the circle). But I'm not able to calculate the third one!

triangle = {
x1: image.width / 2 + radius * cos((rotationAngle * PI / 180)),
y1: image.height / 2 + radius * sin((rotationAngle * PI / 180)),

x2: image.width / 2 + radius * cos(((rotationAngle + triangleSize) * PI / 180)),
y2: image.height / 2 + radius * sin(((rotationAngle + triangleSize) * PI / 180))
}


Since I know that the opposite sides of the triangle are of equal length, I only have to calculate the last point. I know the theoretical path:

• Calculate gradient A of distance xy1/xy2
• Calculate the center M of distance xy1/xy2
• Calculate the normale from A with a certain length from the center M calculate = h of triangle

Nevertheless I have problems to implement it and hope that someone will help me. Thanks in advance.

• As the formulas are now, the base of the triangle isn't horizontal when rotated 0 degrees - is this what you intended? Aug 12, 2018 at 18:06

You need to define the height of the triangle, in the code segment below I have used a height of one tenth of the radius. I have also made it that the apex of the triangle is the part at exactly the rotation angle.

   triangle = {
x3: image.width / 2 + 1.1 * radius * cos((rotationAngle * PI / 180)),
y3: image.height / 2 + 1.1 * radius * sin((rotationAngle * PI / 180)),
x1: image.width / 2 + radius * cos(((rotationAngle - 0.5 * triangleSize) * PI / 180)),
y1: image.height / 2 + radius * sin(((rotationAngle - 0.5 * triangleSize) * PI / 180))
x2: image.width / 2 + radius * cos(((rotationAngle + 0.5 * triangleSize) * PI / 180)),
y2: image.height / 2 + radius * sin(((rotationAngle + 0.5 * triangleSize) * PI / 180))
}

• Note that if he wanted an equilateral triangle, the height follows from triangleSize Aug 13, 2018 at 1:35
• If you want it to scale with trianglesize you can replace 1.1 with ( 1 + trianglesize * PI * sqrt(3) / 360 )
– WW1
Aug 13, 2018 at 2:14