struct ThreeRealNums
{
double n1;
double n2;
double n3;
};
ThreeRealNums TriangleBisector(int A, int B, int C)
{
// Angle bisector formula: t_a = (2*b*c*cos(A/2))/(b+c)
// Or simplified: t_a = sqrt(b*c*((b+c)^2 - a^2)) / (b+c)
// where t_a is bisector from vertex A to side a
ThreeRealNums result;
// Bisector from A to side a (opposite to A)
double t_a = sqrt((double)B*C*((B+C)*(B+C) - A*A)) / (B + C);
result.n1 = t_a;
// Bisector from B to side b (opposite to B)
double t_b = sqrt((double)A*C*((A+C)*(A+C) - B*B)) / (A + C);
result.n2 = t_b;
// Bisector from C to side c (opposite to C)
double t_c = sqrt((double)A*B*((A+B)*(A+B) - C*C)) / (A + B);
result.n3 = t_c;
return result;
}
|