On a right angled triangle, if the user inputs only ONE side length (not the hypotenuse) and only ONE angle, what code is required to work out the hypotenuse? I know how to work out the final side and the remaining angle once I have this.
It depend on which side: opposite of adjanced to the angle. If it is oppsosite, you need to divide side by sine of the angle, otherwise you need to divide side by cosine
could you give me an example of this in code please? I've been trying to divide my side by the sine of the angle but it doesn't appear to be correct. My code is below.
#include<iostream>
#include<cmath>
int main ()
{
constdouble Pi = std::acos(-1);
constdouble side_a = 4.0;
constdouble angle_a = Pi / 3.0; //Adjanced angle
constdouble angle_b = Pi / 6.0; //opposite angle is 30°, so it is half of hypot
double hypot1 = side_a / std::sin(angle_b); //Make sure that both calculation methods
double hypot2 = side_a / std::cos(angle_a); //give the same result
std::cout << hypot1 << '\n' << hypot2;
}