📜  与坐标轴的椭圆的任何切线形成的三角形的最小面积

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

给定两个整数AB ,用方程(x 2 / A 2 ) + (y 2 / B 2 ) = 1表示椭圆的长半轴和半短轴的长度任务是找到与坐标轴的椭圆的任何切线形成的三角形的最小面积。

例子:

方法:

这个想法是基于观察到上图中椭圆上坐标(A * cosθ, B * sinθ)处的切线方程为:

PQ的坐标分别是(A/cosθ,0)(0,B/sinθ)
由椭圆的切线和坐标轴形成的三角形面积由下式给出:

为了最小化面积, sin2θ的值应该尽可能大,即 1。
因此,可能的最小面积是A * B

下面是上述方法的实现:

C++
// C++ program for the above approach
#include 
using namespace std;
 
// Function to find the minimum area
// of triangle formed by any tangent
// to ellipse with the coordinate axes
void minimumTriangleArea(int a, int b)
{
    // Stores the minimum area
    int area = a * b;
 
    // Print the calculated area
    cout << area;
}
 
// Driver Code
int main()
{
    int a = 1, b = 2;
    minimumTriangleArea(a, b);
 
    return 0;
}


Java
// Java program for the above approach
class GFG{
 
// Function to find the minimum area
// of triangle formed by any tangent
// to ellipse with the coordinate axes
static void minimumTriangleArea(int a, int b)
{
     
    // Stores the minimum area
    int area = a * b;
 
    // Print the calculated area
    System.out.println(area);
}
 
// Driver Code
public static void main(String[] args)
{
    int a = 1, b = 2;
     
    minimumTriangleArea(a, b);
}
}
 
// This code is contributed by AnkThon


Python3
# Python3 program for the above approach
 
# Function to find the minimum area
# of triangle formed by any tangent
# to ellipse with the coordinate axes
def minimumTriangleArea(a, b):
     
    # Stores the minimum area
    area = a * b
 
    # Print the calculated area
    print(area)
 
# Driver Code
a = 1
b = 2
 
minimumTriangleArea(a, b)
 
# This code is contributed by rohitsingh07052


C#
// C# program for the above approach
using System;
 
class GFG{
     
// Function to find the minimum area
// of triangle formed by any tangent
// to ellipse with the coordinate axes
static void minimumTriangleArea(int a, int b)
{
     
    // Stores the minimum area
    int area = a * b;
 
    // Print the calculated area
    Console.WriteLine(area);
}
 
// Driver Code
public static void Main()
{
    int a = 1, b = 2;
     
    minimumTriangleArea(a, b);
}
}
 
// This code is contributed by ukasp


Javascript
// JavaScript program for the above approach
 
// Function to find the minimum area
// of triangle formed by any tangent
// to ellipse with the coordinate axes
function minimumTriangleArea(a, b)
{
     
    // Stores the minimum area
    var area = a * b
 
    // Print the calculated area
   console.log(area)
     
}
 
// Driver Code
var a = 1
var b = 2
 
minimumTriangleArea(a, b)
 
// This code is contributed by AnkThon


输出
2

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

如果您希望与专家一起参加现场课程,请参阅DSA 现场工作专业课程学生竞争性编程现场课程