Here you can find the source of circleCentre(double x1, double y1, double x2, double y2, double x3, double y3)
public static Point2D circleCentre(double x1, double y1, double x2, double y2, double x3, double y3)
//package com.java2s; /*//from w ww . jav a 2s. co m * GeoTools - The Open Source Java GIS Toolkit * http://geotools.org * * (C) 2001-2008, Open Source Geospatial Foundation (OSGeo) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. */ import java.awt.geom.Point2D; public class Main { public static Point2D circleCentre(double x1, double y1, double x2, double y2, double x3, double y3) { x2 -= x1; x3 -= x1; y2 -= y1; y3 -= y1; final double sq2 = (x2 * x2 + y2 * y2); final double sq3 = (x3 * x3 + y3 * y3); final double x = (y2 * sq3 - y3 * sq2) / (y2 * x3 - y3 * x2); return new Point2D.Double(x1 + 0.5 * x, y1 + 0.5 * (sq2 - x * x2) / y2); } }