Equation of a circle given center and radius

#include<bits/stdc++.h>
#define ll long long

// input: center (x1, y1) and radius (r) of a circle
// output: (a, b, c) represents the equation: x^2 + a*x + y^2 + b*y = c
template <typename T> vector<T> circle_equation(T x1, T y1, T r) { 
    T a = -2 * x1; 
  
    T b = -2 * y1; 
  
    T c = (r * r) - (x1 * x1) - (y1 * y1); 
  
    vector<T> formula = {a, b, c};
    return formula;
    
} 

Leave a Reply