var currentMode = 'center';
function switchTab(mode) {
currentMode = mode;
document.getElementById('mode-center').classList.toggle('hidden', mode !== 'center');
document.getElementById('mode-points').classList.toggle('hidden', mode !== 'points');
document.getElementById('tab-center').classList.toggle('active', mode === 'center');
document.getElementById('tab-points').classList.toggle('active', mode === 'points');
}
function calculateCircle() {
var h, k, r, rSquared;
if (currentMode === 'center') {
h = parseFloat(document.getElementById('centerX').value);
k = parseFloat(document.getElementById('centerY').value);
r = parseFloat(document.getElementById('radius').value);
} else {
var x1 = parseFloat(document.getElementById('p1x').value);
var y1 = parseFloat(document.getElementById('p1y').value);
var x2 = parseFloat(document.getElementById('p2x').value);
var y2 = parseFloat(document.getElementById('p2y').value);
h = (x1 + x2) / 2;
k = (y1 + y2) / 2;
var dist = Math.sqrt(Math.pow(x2 – x1, 2) + Math.pow(y2 – y1, 2));
r = dist / 2;
}
if (isNaN(h) || isNaN(k) || isNaN(r) || r 0 ? "- " + h : "+ " + Math.abs(h)) + ")²";
var kPart = k === 0 ? "y²" : "(y " + (k > 0 ? "- " + k : "+ " + Math.abs(k)) + ")²";
var standardStr = hPart + " + " + kPart + " = " + rSquared.toFixed(2);
// General Form: x² + y² + Dx + Ey + F = 0
// D = -2h, E = -2k, F = h² + k² – r²
var D = -2 * h;
var E = -2 * k;
var F = (h * h) + (k * k) – rSquared;
var generalStr = "x² + y²";
if (D !== 0) generalStr += (D > 0 ? " + " : " – ") + Math.abs(D) + "x";
if (E !== 0) generalStr += (E > 0 ? " + " : " – ") + Math.abs(E) + "y";
if (F !== 0) generalStr += (F > 0 ? " + " : " – ") + Math.abs(F.toFixed(2));
generalStr += " = 0″;
// Outputs
document.getElementById('resStandard').innerText = standardStr;
document.getElementById('resGeneral').innerText = generalStr;
document.getElementById('resArea').innerText = (Math.PI * rSquared).toFixed(4);
document.getElementById('resCirc').innerText = (2 * Math.PI * r).toFixed(4);
document.getElementById('resDiam').innerText = (2 * r).toFixed(4);
document.getElementById('results').style.display = 'block';
}
Understanding the Equation of a Circle
A circle is defined as the set of all points in a plane that are at a fixed distance, known as the radius, from a fixed point called the center. In coordinate geometry, we represent this relationship using algebraic equations.
Standard Form
The standard form of a circle's equation is the most intuitive way to describe it. It is written as:
(x – h)² + (y – k)² = r²
(h, k): The coordinates of the center point.
r: The radius of the circle.
(x, y): Any point on the circumference.
General Form
The general form is the expanded version of the standard form. It is typically expressed as:
x² + y² + Dx + Ey + F = 0
To convert from general form back to standard form, one must use the method of completing the square for both the x and y variables.
How to Use This Calculator
This calculator provides two primary methods for finding the equation of a circle:
Center and Radius: Simply input the (h, k) coordinates and the radius length. This is useful for basic homework problems.
Two Points (Diameter): If you know the two endpoints of the circle's diameter, the calculator finds the midpoint to determine the center and calculates the distance between them to find the radius.
Practical Examples
Example 1: Find the equation of a circle with center (3, -2) and radius 4. Solution: Plug into standard form: (x – 3)² + (y – (-2))² = 4² → (x – 3)² + (y + 2)² = 16.
Example 2: Diameter endpoints are (0,0) and (6,8). Solution: Center is the midpoint: ((0+6)/2, (0+8)/2) = (3, 4). Distance of diameter = 10, so radius = 5. Equation: (x – 3)² + (y – 4)² = 25.
Frequently Asked Questions
Q: Can a circle have a negative radius?
A: No. Radius represents distance, which must be a positive real number. If r = 0, the equation represents a single point.
Q: What if the center is at the origin?
A: If the center is (0,0), the equation simplifies to the classic Pythagorean form: x² + y² = r².
Q: How do I find the area and circumference?
A: Use the formulas: Area = πr² and Circumference = 2πr. Our calculator provides these values automatically.