Here you can find the source of circleCentre(double x1, double y1, double x2, double y2, double x3, double y3)
Parameter | Description |
---|---|
x1 | <var>x</var> value of the first point. |
y1 | <var>y</var> value of the first point. |
x2 | <var>x</var> value of the second point. |
y2 | <var>y</var> value of the second point. |
x3 | <var>x</var> value of the third point. |
y3 | <var>y</var> value of the third point. |
public static Point2D.Double circleCentre(double x1, double y1, double x2, double y2, double x3, double y3)
//package com.java2s; /*// ww w. j ava 2 s. c o m * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.awt.geom.Point2D; public class Main { /** * Returns a circle passing by the 3 given points. The distance between the returned * point and any of the given points will be constant; it is the circle radius. * * @param x1 <var>x</var> value of the first point. * @param y1 <var>y</var> value of the first point. * @param x2 <var>x</var> value of the second point. * @param y2 <var>y</var> value of the second point. * @param x3 <var>x</var> value of the third point. * @param y3 <var>y</var> value of the third point. * @return A circle passing by the given points. * * @todo This method is used by Geotk (a sandbox for code that may migrate to SIS), but not yet by SIS. * We temporarily keep this code here, but may delete or move it elsewhere in a future SIS version * depending whether we port to SIS the sandbox code. */ public static Point2D.Double 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); } }