Length of remaining two sides of a Triangle from a given side and its adjacent angles
Given the length of a side a of a triangle and its adjacent angles B and C, the task is to find the remaining two sides of the triangle.
Input: a = 5, B = 62.2, C = 33.5
Output: 4.44, 2.77
Explanation
The remaining two sides of the triangle are b = 4.44488228556699 and c = 2.7733977979419038
Input: a = 12, B = 60, C = 30
Output: 10.39, 5.99
Explanation
The remaining two sides of the triangle are b = 10.392304845413264 and c = 5.999999999999999
Approach:
- The remaining angle can be calculated by the angle sum theorem in a triangle:
- The other two sides of triangle can be computed using sine formula:
Below is the implementation of the above approach:
C++
#include<bits/stdc++.h>
using namespace std;
void findSide( float a, float B, float C)
{
float A = 180 - C - B;
float radA = M_PI * (A / 180);
float radB = M_PI * (B / 180);
float radC = M_PI * (C / 180);
float b = a / sin (radA) * sin (radB);
float c = a / sin (radA) * sin (radC);
cout << fixed << setprecision(15) << b << " " ;
cout << fixed << setprecision(15) << c;
}
int main()
{
int a = 12, B = 60, C = 30;
findSide(a, B, C);
}
|
Java
import java.util.*;
class GFG{
static void findSide( double a, double B,
double C)
{
double A = 180 - C - B;
double radA = (Math.PI * (A / 180 ));
double radB = (Math.PI * (B / 180 ));
double radC = (Math.PI * (C / 180 ));
double b = (a / Math.sin(radA) *
Math.sin(radB));
double c = (a / Math.sin(radA) *
Math.sin(radC));
System.out.printf( "%.15f" , b);
System.out.printf( " %.15f" , c);
}
public static void main(String[] args)
{
int a = 12 , B = 60 , C = 30 ;
findSide(a, B, C);
}
}
|
Python3
import math
def findSide(a, B, C):
A = 180 - C - B
radA = math.pi * (A / 180 )
radB = math.pi * (B / 180 )
radC = math.pi * (C / 180 )
b = a / math.sin(radA) * math.sin(radB)
c = a / math.sin(radA) * math.sin(radC)
return b, c
a = 12
B = 60
C = 30
b, c = findSide(a, B, C)
print (b, c)
|
C#
using System;
class GFG{
static void findSide( float a,
double B, double C)
{
double A = 180 - C - B;
double radA = (Math.PI * (A / 180));
double radB = (Math.PI * (B / 180));
double radC = (Math.PI * (C / 180));
double b = (a / Math.Sin(radA) *
Math.Sin(radB));
double c = (a / Math.Sin(radA) *
Math.Sin(radC));
Console.Write( "{0:F15}" , b);
Console.Write( "{0:F15}" , c);
}
public static void Main(String[] args)
{
int a = 12, B = 60, C = 30;
findSide(a, B, C);
}
}
|
Javascript
<script>
function findSide(a, B, C)
{
var A = 180 - C - B;
var radA = Math.PI * (A / 180);
var radB = Math.PI * (B / 180);
var radC = Math.PI * (C / 180);
var b = a / Math.sin(radA) * Math.sin(radB);
var c = a / Math.sin(radA) * Math.sin(radC);
document.write( b + " " );
document.write( c);
}
var a = 12, B = 60, C = 30;
findSide(a, B, C);
</script>
|
Output:
10.392304845413264 5.999999999999999
Time Complexity: O(1)
Auxiliary Space: O(1)
Last Updated :
28 Jan, 2022
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...