📜  带推导、示例和实现的正弦规则

📅  最后修改于: 2021-10-23 08:03:48             🧑  作者: Mango

给定角度(以度为单位) AC和边c ,对应于下图,任务是找到剩余的两条边ab

例子:

方法:想法是使用正弦规则。它指出任何三角形的边都与它们对角的正弦成正比。 a / Sin(A) = b / Sin(B) = c / Sin(C) 。推导描述如下:

请按照以下步骤解决问题:

  • 将角度AC从度数更改为弧度,以便能够在内置函数中使用。
  • 使用三角形的角之和为 180 度的观察结果计算角度B。
  • 使用正弦规则计算边ab

下面是上述方法的实现:

C++14
// C++ program for the above approach
#include 
using namespace std;
 
// Function to calculate remaining two sides
void findSides(double A, double C, double c)
{
    // Calculate angle B
    double B = 180 - (A + C);
 
    // Convert angles to their respective radians for
    // using trigonometric functions
    A = A * (3.14159 / 180);
    C = C * (3.14159 / 180);
    B = B * (3.14159 / 180);
 
    // Sine rule
    double a = (c / sin(C)) * sin(A);
    double b = (c / sin(C)) * sin(B);
 
    // Precision of 2 decimal spaces
    cout << fixed << setprecision(2);
 
    // Print the answer
    cout << a << endl;
    cout << b << endl;
}
 
// Driver Code
int main()
{
    // Input
    double A = 45.0;
    double C = 35.0;
    double c = 23;
 
    // Function Call
    findSides(A, C, c);
    return 0;
}


Java
// Java program for the above approach
class GFG{
 
// Function to calculate remaining two sides
static void findSides(double A, double C,
                      double c)
{
     
    // Calculate angle B
    double B = 180 - (A + C);
 
    // Convert angles to their respective
    // radians for using trigonometric functions
    A = A * (3.14159 / 180);
    C = C * (3.14159 / 180);
    B = B * (3.14159 / 180);
 
    // Sine rule
    double a = (c / Math.sin(C)) * Math.sin(A);
    double b = (c / Math.sin(C)) * Math.sin(B);
 
    // Print the answer
    System.out.println(String.format("%.2f", a));
    System.out.println(String.format("%.2f", b));
}
 
// Driver code
public static void main(String[] args)
{
     
    // Input
    double A = 45.0;
    double C = 35.0;
    double c = 23;
 
    // Function Call
    findSides(A, C, c);
}
}
 
// This code is contributed by abhinavjain194


Python3
# Python3 program for the above approach
import math
 
# Function to calculate remaining two sides
def findSides(A, C, c):
     
    # Calculate angle B
    B = 180 - (A + C)
 
    # Convert angles to their respective radians
    # for using trigonometric functions
    A = A * (3.14159 / 180)
    C = C * (3.14159 / 180)
    B = B * (3.14159 / 180)
 
    # Sine rule
    a = (c / math.sin(C)) * math.sin(A)
    b = (c / math.sin(C)) * math.sin(B)
 
    # Precision of 2 decimal spaces
 
    # Print the answer
    print("{0:.2f}".format(a))
    print("{0:.2f}".format(b))
 
# Driver Code
 
# Input
A = 45.0
C = 35.0
c = 23
 
# Function Call
findSides(A, C, c)
 
# This code is contributed by target_2


C#
// C# program for the above approach
using System;
class GFG{
 
// Function to calculate remaining two sides
static void findSides(double A, double C,
                      double c)
{
     
    // Calculate angle B
    double B = 180 - (A + C);
 
    // Convert angles to their respective
    // radians for using trigonometric functions
    A = A * (3.14159 / 180);
    C = C * (3.14159 / 180);
    B = B * (3.14159 / 180);
 
    // Sine rule
    double a = (c / Math.Sin(C)) * Math.Sin(A);
    double b = (c / Math.Sin(C)) * Math.Sin(B);
 
    // Print the answer
    Console.WriteLine("{0:F2}",a);
    Console.WriteLine("{0:F2}",b);
}
 
// Driver code
public static void Main(String[] args)
{
     
    // Input
    double A = 45.0;
    double C = 35.0;
    double c = 23;
 
    // Function Call
    findSides(A, C, c);
}
}
 
// This code is contributed by shivanisinghss2110


Javascript


输出
28.35
39.49

时间复杂度: O(1)
辅助空间: O(1)