📜  圆心和半径的方程

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

给定圆心 (x1, y1) 及其半径 r,求圆心为 (x1, y1) 且半径为 r 的圆的方程。
例子:

方法:
给定圆心 (x1, y1) 及其半径 r,我们必须找到圆心为 (x1, y1) 且半径为 r 的圆的方程。
圆心为 (x1, y1) 且半径为 r 的圆方程由下式给出:-

${(x - x1)^{2} + (y - y1)^{2} = (r)^{2}}$

关于扩展上述方程

${(x)^{2} + (x1)^{2} - (2 * x1 * x) +  (y)^{2} + (y1)^{2} - (2 * y1 * y) = (r)^{2}}$

在安排上面我们得到

${(x)^{2} - (2 * x1 * x) +  (y)^{2} - (2 * y1 * y) = (r)^{2} - (x1)^{2} - (y1)^{2} }$

下面是上述方法的实现:

C++
// CPP program to find the equation
// of circle.
#include 
using namespace std;
 
// Function to find the equation of circle
void circle_equation(double x1, double y1, double r)
{
    double a = -2 * x1;
 
    double b = -2 * y1;
 
    double c = (r * r) - (x1 * x1) - (y1 * y1);
 
    // Printing result
    cout << "x^2 + (" << a << " x) + ";
    cout << "y^2 + (" << b << " y) = ";
    cout << c << "." << endl;
}
 
// Driver code
int main()
{
    double x1 = 2, y1 = -3, r = 8;
    circle_equation(x1, y1, r);
    return 0;
}


Java
// Java program to find the equation
// of circle.
import java.util.*;
 
class solution
{
 
 // Function to find the equation of circle
static void circle_equation(double x1, double y1, double r)
{
    double a = -2 * x1;
 
    double b = -2 * y1;
 
    double c = (r * r) - (x1 * x1) - (y1 * y1);
 
    // Printing result
    System.out.print("x^2 + (" +a+ " x) + ");
     System.out.print("y^2 + ("+b + " y) = ");
     System.out.println(c +"." );
}
 
// Driver code
public static void main(String arr[])
{
    double x1 = 2, y1 = -3, r = 8;
    circle_equation(x1, y1, r);
  
}
 
}


Python3
# Python3 program to find the
# equation of circle.
 
# Function to find the
# equation of circle
def circle_equation(x1, y1, r):
    a = -2 * x1;
 
    b = -2 * y1;
 
    c = (r * r) - (x1 * x1) - (y1 * y1);
 
    # Printing result
    print("x^2 + (", a, "x) + ", end = "");
    print("y^2 + (", b, "y) = ", end = "");
    print(c, ".");
 
# Driver code
x1 = 2;
y1 = -3;
r = 8;
circle_equation(x1, y1, r);
 
# This code is contributed
# by mits


C#
// C# program to find the equation
// of circle.
using System;
 
class GFG
{
 
// Function to find the equation of circle
public static void circle_equation(double x1,
                                   double y1,
                                   double r)
{
    double a = -2 * x1;
 
    double b = -2 * y1;
 
    double c = (r * r) - (x1 * x1) - (y1 * y1);
 
    // Printing result
    Console.Write("x^2 + (" + a + " x) + ");
    Console.Write("y^2 + ("+ b + " y) = ");
    Console.WriteLine(c + "." );
}
 
// Driver code
public static void Main(string []arr)
{
    double x1 = 2, y1 = -3, r = 8;
    circle_equation(x1, y1, r);
}
}
 
// This code is contributed
// by SoumkMondal


PHP


Javascript


输出:
x^2 + (-4 x) + y^2 + (6 y) = 51.