001/******************************************************************************* 002 * This software is provided as a supplement to the authors' textbooks on digital 003 * image processing published by Springer-Verlag in various languages and editions. 004 * Permission to use and distribute this software is granted under the BSD 2-Clause 005 * "Simplified" License (see http://opensource.org/licenses/BSD-2-Clause). 006 * Copyright (c) 2006-2023 Wilhelm Burger, Mark J. Burge. All rights reserved. 007 * Visit https://imagingbook.com for additional details. 008 ******************************************************************************/ 009package imagingbook.common.geometry.fitting.circle.geometric; 010 011import imagingbook.common.geometry.basic.Pnt2d; 012import imagingbook.common.geometry.circle.GeometricCircle; 013 014import java.util.List; 015 016/** 017 * Common interface for geometric circle fits. 018 * @author WB 019 * 020 */ 021public interface CircleFitGeometric { 022 023 public enum FitType { 024 CoordinateBased, 025 DistanceBased 026 } 027 028 public static CircleFitGeometric getFit(FitType type, Pnt2d[] points, GeometricCircle initCircle) { 029 switch (type) { 030 case CoordinateBased: 031 return new CircleFitGeometricCoord(points, initCircle); 032 case DistanceBased: 033 return new CircleFitGeometricDist(points, initCircle); 034 } 035 //throw new IllegalArgumentException("unknown geometric fit type: " + type); 036 return null; 037 } 038 039 public static boolean VERBOSE = false; 040 public static boolean RecordHistory = false; 041 042 public abstract double[] getParameters(); 043 public abstract int getIterations(); 044 public abstract List<double[]> getHistory(); 045 046 /** 047 * Returns the geometric circle produced by this fit. 048 * @return a {@link GeometricCircle} instance 049 */ 050 public default GeometricCircle getCircle() { 051 return new GeometricCircle(getParameters()); 052 } 053 054}