Package org.tinfour.common
Class Circumcircle
- java.lang.Object
-
- org.tinfour.common.Circumcircle
-
public class Circumcircle extends Object
Provides center coordinates and radius for a circumcircle.
-
-
Constructor Summary
Constructors Constructor Description Circumcircle()Standard constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcompute(double x0, double y0, double x1, double y1, double x2, double y2)Computes the circumcircle for the specified vertices and stores results in elements of this instance.booleancompute(Vertex a, Vertex b, Vertex c)Computes the circumcircle for the specified vertices and stores results in elements of this instance.static CircumcirclecomputeCircumcircle(Vertex a, Vertex b, Vertex c)Computes the circumcircle for the specified vertices.voidcopy(Circumcircle c)Copies the content of the specified circumcircle instance.Rectangle2DgetBounds()Gets the bounds of the circumcircle.VertexgetCircumcenter()Gets a vertex representing the center of this circumcircle.doublegetRadius()Gets the radius of the circumcircledoublegetRadiusSq()Gets the square of the radius of the circumcircle.doublegetX()Gets the x coordinate of the center of the circumcircle.doublegetY()Gets the y coordinate of the center of the circumcircle.voidsetCircumcenter(double x, double y, double r2)Sets the coordinate for the circumcenter and radius for this instance.StringtoString()
-
-
-
Method Detail
-
getRadiusSq
public double getRadiusSq()
Gets the square of the radius of the circumcircle.- Returns:
- for a non-degenerate triangle, a positive floating point value (potentially Infinity for a ghost triangle).
-
getRadius
public double getRadius()
Gets the radius of the circumcircle- Returns:
- for a non-degenerate triangle, a positive floating point value
-
getX
public double getX()
Gets the x coordinate of the center of the circumcircle.- Returns:
- a valid floating point value.
-
getY
public double getY()
Gets the y coordinate of the center of the circumcircle.- Returns:
- a valid floating point value.
-
getCircumcenter
public Vertex getCircumcenter()
Gets a vertex representing the center of this circumcircle.- Returns:
- a valid vertex (with z coordinate set to NaN).
-
copy
public void copy(Circumcircle c)
Copies the content of the specified circumcircle instance.- Parameters:
c- a valid circumcircle instance.
-
computeCircumcircle
public static Circumcircle computeCircumcircle(Vertex a, Vertex b, Vertex c)
Computes the circumcircle for the specified vertices. Vertices are assumed to be given in counterclockwise order. Any null inputs for the vertices results in an infinite circumcircle. Vertices resulting in a degenerate (nearly zero area) triangle result in an infinite circumcircle.- Parameters:
a- the initial vertex.b- the second vertex.c- the third vertex.- Returns:
- a valid circumcircle.
-
compute
public boolean compute(Vertex a, Vertex b, Vertex c)
Computes the circumcircle for the specified vertices and stores results in elements of this instance. Vertices are assumed to be given in counterclockwise order. Any null inputs for the vertices results in an infinite circumcircle. Vertices resulting in a degenerate (nearly zero area) triangle result in an infinite circumcircle.- Parameters:
a- the initial vertex.b- the second vertex.c- the third vertex.- Returns:
- true if the computation successfully yields a circle of finite radius; otherwise, false.
-
compute
public void compute(double x0, double y0, double x1, double y1, double x2, double y2)Computes the circumcircle for the specified vertices and stores results in elements of this instance. Vertices are assumed to be given in counterclockwise order. Any null inputs for the vertices results in an infinite circumcircle. Vertices resulting in a degenerate (nearly zero area) triangle result in an infinite circumcircle.- Parameters:
x0- the x coordinate of the first vertexy0- the y coordinate of the first vertexx1- the x coordinate of the second vertexy1- the y coordinate of the second vertexx2- the x coordinate of the third vertexy2- the y coordinate of the third vertex
-
setCircumcenter
public void setCircumcenter(double x, double y, double r2)Sets the coordinate for the circumcenter and radius for this instance.- Parameters:
x- the x coordinate for the circumcentery- the y coordinate for the circumcenterr2- the square of the radius for the circumcircle
-
getBounds
public Rectangle2D getBounds()
Gets the bounds of the circumcircle.- Returns:
- a valid rectangle instance.
-
-