math.geom2d.conic
Class Circle2D

Package class diagram package Circle2D
java.lang.Object
  extended by math.geom2d.curve.AbstractContinuousCurve2D
      extended by math.geom2d.curve.AbstractSmoothCurve2D
          extended by math.geom2d.conic.Ellipse2D
              extended by math.geom2d.conic.Circle2D
All Implemented Interfaces:
Serializable, Cloneable, CircleLine2D, CirculinearBoundary2D, CirculinearContinuousCurve2D, CirculinearContour2D, CirculinearCurve2D, CirculinearElement2D, CirculinearShape2D, ContinuousCirculinearCurve2D, CircularShape2D, Conic2D, ContinuousCurve2D, Curve2D, SmoothCurve2D, Boundary2D, ContinuousBoundary2D, ContinuousOrientedCurve2D, OrientedCurve2D, SmoothBoundary2D, SmoothOrientedCurve2D, Shape2D

public class Circle2D
extends Ellipse2D
implements Cloneable, CirculinearElement2D, CirculinearBoundary2D, CircularShape2D, CircleLine2D

A circle in the plane, defined as the set of points located at an equal distance from the circle center. A circle is a particular ellipse, with first and second axis length equal.

Author:
dlegland
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface math.geom2d.conic.Conic2D
Conic2D.Type
 
Field Summary
protected  double r
          the radius of the circle.
 
Fields inherited from class math.geom2d.conic.Ellipse2D
direct, r1, r2, theta, xc, yc
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY
 
Constructor Summary
Circle2D()
          Empty constructor: center 0,0 and radius 0.
Circle2D(double xcenter, double ycenter, double radius)
          Create a new circle with specified center and radius
Circle2D(double xcenter, double ycenter, double radius, boolean direct)
          Create a new circle with specified center, radius and orientation.
Circle2D(Point2D center, double radius)
          Create a new circle with specified point center and radius
Circle2D(Point2D center, double radius, boolean direct)
          Create a new circle with specified center, radius and orientation
 
Method Summary
 GeneralPath appendPath(GeneralPath path)
          Add the path of the ellipse to the given path.
 CurveSet2D<? extends CircularShape2D> clip(Box2D box)
          Clip the circle by a box.
 Circle2D clone()
          Overrides Object declaration to ensure Curve2D implementation are cloned as Curve2D.
 boolean contains(double x, double y)
          Return true if the point (x, y) lies exactly on the circle.
static Circle2D create(Point2D center, double radius)
          Creates a circle from a center and a radius.
static Circle2D create(Point2D p1, Point2D p2, Point2D p3)
          Creates a circle containing 3 points.
 void draw(Graphics2D g2)
          Draws the curve on the given Graphics2D object.
 boolean equals(Object obj)
           
 CirculinearDomain2D getBuffer(double dist)
          Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.
 double[] getConicCoefficients()
          Returns Cartesian equation of the circle:
 Conic2D.Type getConicType()
           
 Collection<? extends Circle2D> getContinuousCurves()
          Returns the collection of continuous curves which constitute this curve.
 double getDistance(double x, double y)
          get the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e.
 double getDistance(Point2D point)
          get the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
 double getEccentricity()
          Return 0, which is the eccentricity of a circle by definition.
 Point2D getFirstPoint()
          Get the first point of the circle, which is the same as the last point.
 Point2D getFocus1()
          Return the first focus, which for a circle is the same point as the center.
 Point2D getFocus2()
          Return the second focus, which for a circle is the same point as the center.
static Collection<Point2D> getIntersections(Circle2D circle1, Circle2D circle2)
           
static Collection<Point2D> getIntersections(CircularShape2D circle, LinearShape2D line)
          Compute intersections of a circle with a line.
 Collection<Point2D> getIntersections(LinearShape2D line)
          Compute intersections of the circle with a line.
 Point2D getLastPoint()
          Get the last point of the circle, which is the same as the first point.
 double getLength()
          Returns perimeter of the circle (equal to 2*PI*radius).
 double getLength(double pos)
           
 Circle2D getParallel(double d)
          Returns the parallel circle located at a distance d from this circle.
 Point2D getPoint(double t)
          Get the position of the curve from internal parametric representation, depending on the parameter t.
 double getPosition(double length)
           
 double getPosition(Point2D point)
          Get position of the point on the curve.
 double getRadius()
           
 Circle2D getReverseCurve()
          Returns the circle with same center and same radius, but with the other orientation.
 double getSignedDistance(double x, double y)
          The same as getSignedDistance(Point2D), but by passing 2 double as arguments.
 double getSignedDistance(Point2D point)
          Get the signed distance of the curve to the given point: this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape.
 Collection<? extends Circle2D> getSmoothPieces()
          Returns a set of smooth curves, which contains only the circle.
 CircleArc2D getSubCurve(double t0, double t1)
          Returns a new CircleArc2D.
 Circle2D getSupportingCircle()
          Returns the circle itself.
 Vector2D getTangent(double t)
           
 boolean isCircle()
           
 boolean isInside(Point2D point)
          Test whether the point is inside the circle.
 void setCircle(double xc, double yc, double r)
          Deprecated. conics will become immutable in a future release
 void setCircle(Point2D center, double r)
          Deprecated. conics will become immutable in a future release
 void setRadius(double radius)
          Deprecated. conics will become immutable in a future release
 String toString()
           
 CircleLine2D transform(CircleInversion2D inv)
          Transforms the shape by a circle inversion.
 
Methods inherited from class math.geom2d.conic.Ellipse2D
contains, create, create, create, create, create, fill, getAngle, getBoundaryCurves, getBoundingBox, getCenter, getCurvature, getDomain, getGeneralPath, getProjectedPoint, getProjectedVector, getRho, getSemiMajorAxisLength, getSemiMinorAxisLength, getT0, getT1, getVector1, getVector2, getWindingAngle, isBounded, isClosed, isDirect, isEmpty, project, reduceCentered, setCenter, setCenter, setEllipse, setEllipse, setEllipse, setEllipse, transform, transformCentered
 
Methods inherited from class math.geom2d.curve.AbstractSmoothCurve2D
getLeftTangent, getRightTangent, getSingularPoints, isSingular
 
Methods inherited from class math.geom2d.curve.AbstractContinuousCurve2D
getAsAWTShape, getAsPolyline, wrapCurve
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface math.geom2d.curve.ContinuousCurve2D
getAsPolyline, getLeftTangent, getRightTangent, isClosed
 
Methods inherited from interface math.geom2d.curve.Curve2D
getAsAWTShape, getSingularPoints, getT0, getT1, isSingular, project
 
Methods inherited from interface math.geom2d.Shape2D
contains, getBoundingBox, isBounded, isEmpty
 
Methods inherited from interface math.geom2d.domain.SmoothBoundary2D
transform
 
Methods inherited from interface math.geom2d.curve.SmoothCurve2D
getCurvature
 
Methods inherited from interface math.geom2d.domain.Boundary2D
fill, getBoundaryCurves, getDomain
 

Field Detail

r

protected double r
the radius of the circle.

Constructor Detail

Circle2D

public Circle2D()
Empty constructor: center 0,0 and radius 0.


Circle2D

public Circle2D(Point2D center,
                double radius)
Create a new circle with specified point center and radius


Circle2D

public Circle2D(Point2D center,
                double radius,
                boolean direct)
Create a new circle with specified center, radius and orientation


Circle2D

public Circle2D(double xcenter,
                double ycenter,
                double radius)
Create a new circle with specified center and radius


Circle2D

public Circle2D(double xcenter,
                double ycenter,
                double radius,
                boolean direct)
Create a new circle with specified center, radius and orientation.

Method Detail

create

public static Circle2D create(Point2D center,
                              double radius)
Creates a circle from a center and a radius.


create

public static Circle2D create(Point2D p1,
                              Point2D p2,
                              Point2D p3)
Creates a circle containing 3 points.


getIntersections

public static Collection<Point2D> getIntersections(Circle2D circle1,
                                                   Circle2D circle2)

getIntersections

public static Collection<Point2D> getIntersections(CircularShape2D circle,
                                                   LinearShape2D line)
Compute intersections of a circle with a line. Return an array of Point2D, of size 0, 1 or 2 depending on the distance between circle and line. If there are 2 intersections points, the first one in the array is the first one on the line.


getRadius

public double getRadius()

setRadius

@Deprecated
public void setRadius(double radius)
Deprecated. conics will become immutable in a future release


setCircle

@Deprecated
public void setCircle(double xc,
                                 double yc,
                                 double r)
Deprecated. conics will become immutable in a future release


setCircle

@Deprecated
public void setCircle(Point2D center,
                                 double r)
Deprecated. conics will become immutable in a future release


getSupportingCircle

public Circle2D getSupportingCircle()
Returns the circle itself.

Specified by:
getSupportingCircle in interface CircularShape2D

getConicType

public Conic2D.Type getConicType()
Specified by:
getConicType in interface Conic2D
Overrides:
getConicType in class Ellipse2D

isCircle

public boolean isCircle()
Overrides:
isCircle in class Ellipse2D

getConicCoefficients

public double[] getConicCoefficients()
Returns Cartesian equation of the circle:

(x-xc)^2 + (y-yc)^2 = r^2, giving:

x^2 + 0*x*y + y^2 -2*xc*x -2*yc*y + xc*xc+yc*yc-r*r = 0.

Specified by:
getConicCoefficients in interface Conic2D
Overrides:
getConicCoefficients in class Ellipse2D

getEccentricity

public double getEccentricity()
Return 0, which is the eccentricity of a circle by definition.

Specified by:
getEccentricity in interface Conic2D
Overrides:
getEccentricity in class Ellipse2D

getFocus1

public Point2D getFocus1()
Return the first focus, which for a circle is the same point as the center.

Overrides:
getFocus1 in class Ellipse2D

getFocus2

public Point2D getFocus2()
Return the second focus, which for a circle is the same point as the center.

Overrides:
getFocus2 in class Ellipse2D

getBuffer

public CirculinearDomain2D getBuffer(double dist)
Description copied from interface: CirculinearShape2D
Computes the buffer of the shape, formed by the set of points located at a distance from the shape that is lower or equal to d.

Specified by:
getBuffer in interface CirculinearShape2D
Parameters:
dist - the maximal distance between a point of the buffer and the shape
Returns:
the buffer of the shape

getParallel

public Circle2D getParallel(double d)
Returns the parallel circle located at a distance d from this circle. For direct circle, distance is positive outside of the circle, and negative inside. This is the contrary for indirect circles.

Specified by:
getParallel in interface CircleLine2D
Specified by:
getParallel in interface CirculinearContinuousCurve2D
Specified by:
getParallel in interface CirculinearContour2D
Specified by:
getParallel in interface CirculinearCurve2D
Specified by:
getParallel in interface CirculinearElement2D
Specified by:
getParallel in interface ContinuousCirculinearCurve2D
Overrides:
getParallel in class Ellipse2D
Parameters:
d - the distance between the original curve and he parallel curve.
Returns:
the parallel curve

getLength

public double getLength()
Returns perimeter of the circle (equal to 2*PI*radius).

Specified by:
getLength in interface CirculinearCurve2D
Returns:
the length of the curve

getLength

public double getLength(double pos)
Specified by:
getLength in interface CirculinearCurve2D
Returns:
the length from the beginning to the position given by pos

getPosition

public double getPosition(double length)
Specified by:
getPosition in interface CirculinearCurve2D
Returns:
the position located at distance 'length' from the origin

transform

public CircleLine2D transform(CircleInversion2D inv)
Description copied from interface: CirculinearShape2D
Transforms the shape by a circle inversion. The result is still an instance a CirculinearShape2D.

Specified by:
transform in interface CircleLine2D
Specified by:
transform in interface CirculinearBoundary2D
Specified by:
transform in interface CirculinearContinuousCurve2D
Specified by:
transform in interface CirculinearContour2D
Specified by:
transform in interface CirculinearCurve2D
Specified by:
transform in interface CirculinearElement2D
Specified by:
transform in interface CirculinearShape2D
Specified by:
transform in interface ContinuousCirculinearCurve2D
Parameters:
inv - the circle inversion
Returns:
the transformed shape

getTangent

public Vector2D getTangent(double t)
Specified by:
getTangent in interface SmoothCurve2D
Overrides:
getTangent in class Ellipse2D

getSmoothPieces

public Collection<? extends Circle2D> getSmoothPieces()
Returns a set of smooth curves, which contains only the circle.

Specified by:
getSmoothPieces in interface CirculinearContinuousCurve2D
Specified by:
getSmoothPieces in interface ContinuousCirculinearCurve2D
Specified by:
getSmoothPieces in interface ContinuousCurve2D
Overrides:
getSmoothPieces in class AbstractSmoothCurve2D

isInside

public boolean isInside(Point2D point)
Test whether the point is inside the circle. The test is performed by translating the point, and re-scaling it such that its coordinates are expressed in unit circle basis.

Specified by:
isInside in interface Boundary2D
Specified by:
isInside in interface OrientedCurve2D
Overrides:
isInside in class Ellipse2D
Parameters:
point - a point in the plane
Returns:
true if the point is on the left side of the curve.

getSignedDistance

public double getSignedDistance(Point2D point)
Description copied from interface: OrientedCurve2D
Get the signed distance of the curve to the given point: this distance is positive if the point lies outside the shape, and is negative if the point lies inside the shape. In this case, absolute value of distance is equals to the distance to the border of the shape.

Specified by:
getSignedDistance in interface OrientedCurve2D
Overrides:
getSignedDistance in class Ellipse2D
Parameters:
point - a point of the plane
Returns:
the signed distance to the curve

getSignedDistance

public double getSignedDistance(double x,
                                double y)
Description copied from interface: OrientedCurve2D
The same as getSignedDistance(Point2D), but by passing 2 double as arguments.

Specified by:
getSignedDistance in interface OrientedCurve2D
Overrides:
getSignedDistance in class Ellipse2D
Parameters:
x - x-coord of a point
y - y-coord of a point
Returns:
the signed distance of the point (x,y) to the curve

getPoint

public Point2D getPoint(double t)
Get the position of the curve from internal parametric representation, depending on the parameter t. This parameter is between the two limits 0 and 2*Math.PI.

Specified by:
getPoint in interface Curve2D
Overrides:
getPoint in class Ellipse2D

getFirstPoint

public Point2D getFirstPoint()
Get the first point of the circle, which is the same as the last point.

Specified by:
getFirstPoint in interface Curve2D
Overrides:
getFirstPoint in class Ellipse2D
Returns:
the first point of the curve

getLastPoint

public Point2D getLastPoint()
Get the last point of the circle, which is the same as the first point.

Specified by:
getLastPoint in interface Curve2D
Overrides:
getLastPoint in class Ellipse2D
Returns:
the last point of the curve.

getPosition

public double getPosition(Point2D point)
Description copied from interface: Curve2D
Get position of the point on the curve. If the point does not belong to the curve, return Double.NaN.

Specified by:
getPosition in interface Curve2D
Overrides:
getPosition in class Ellipse2D
Parameters:
point - a point belonging to the curve
Returns:
the position of the point on the curve

getReverseCurve

public Circle2D getReverseCurve()
Returns the circle with same center and same radius, but with the other orientation.

Specified by:
getReverseCurve in interface CircleLine2D
Specified by:
getReverseCurve in interface CirculinearBoundary2D
Specified by:
getReverseCurve in interface CirculinearContinuousCurve2D
Specified by:
getReverseCurve in interface CirculinearContour2D
Specified by:
getReverseCurve in interface CirculinearCurve2D
Specified by:
getReverseCurve in interface CirculinearElement2D
Specified by:
getReverseCurve in interface ContinuousCirculinearCurve2D
Specified by:
getReverseCurve in interface CircularShape2D
Specified by:
getReverseCurve in interface Conic2D
Specified by:
getReverseCurve in interface ContinuousCurve2D
Specified by:
getReverseCurve in interface Curve2D
Specified by:
getReverseCurve in interface SmoothCurve2D
Specified by:
getReverseCurve in interface Boundary2D
Specified by:
getReverseCurve in interface ContinuousBoundary2D
Specified by:
getReverseCurve in interface ContinuousOrientedCurve2D
Specified by:
getReverseCurve in interface OrientedCurve2D
Specified by:
getReverseCurve in interface SmoothBoundary2D
Specified by:
getReverseCurve in interface SmoothOrientedCurve2D
Overrides:
getReverseCurve in class Ellipse2D

getSubCurve

public CircleArc2D getSubCurve(double t0,
                               double t1)
Returns a new CircleArc2D. t0 and t1 are position on circle.

Specified by:
getSubCurve in interface CirculinearContinuousCurve2D
Specified by:
getSubCurve in interface CirculinearCurve2D
Specified by:
getSubCurve in interface CirculinearElement2D
Specified by:
getSubCurve in interface ContinuousCirculinearCurve2D
Specified by:
getSubCurve in interface CircularShape2D
Specified by:
getSubCurve in interface ContinuousCurve2D
Specified by:
getSubCurve in interface Curve2D
Specified by:
getSubCurve in interface SmoothCurve2D
Specified by:
getSubCurve in interface ContinuousOrientedCurve2D
Specified by:
getSubCurve in interface SmoothOrientedCurve2D
Overrides:
getSubCurve in class Ellipse2D
Parameters:
t0 - position of the start of the sub-curve
t1 - position of the end of the sub-curve
Returns:
the portion of original curve comprised between t0 and t1.

getContinuousCurves

public Collection<? extends Circle2D> getContinuousCurves()
Description copied from interface: Curve2D
Returns the collection of continuous curves which constitute this curve.

Specified by:
getContinuousCurves in interface CirculinearBoundary2D
Specified by:
getContinuousCurves in interface CirculinearCurve2D
Specified by:
getContinuousCurves in interface Curve2D
Overrides:
getContinuousCurves in class Ellipse2D
Returns:
a collection of continuous curves.

getDistance

public double getDistance(Point2D point)
Description copied from interface: Shape2D
get the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.

Specified by:
getDistance in interface Shape2D
Overrides:
getDistance in class Ellipse2D

getDistance

public double getDistance(double x,
                          double y)
Description copied from interface: Shape2D
get the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.

Specified by:
getDistance in interface Shape2D
Overrides:
getDistance in class Ellipse2D

getIntersections

public Collection<Point2D> getIntersections(LinearShape2D line)
Compute intersections of the circle with a line. Return an array of Point2D, of size 0, 1 or 2 depending on the distance between circle and line. If there are 2 intersections points, the first one in the array is the first one on the line.

Specified by:
getIntersections in interface Curve2D
Overrides:
getIntersections in class Ellipse2D

clip

public CurveSet2D<? extends CircularShape2D> clip(Box2D box)
Clip the circle by a box. The result is an instance of CurveSet2D, which contains only instances of CircleArc2D or Circle2D. If the circle is not clipped, the result is an instance of CurveSet2D which contains 0 curves.

Specified by:
clip in interface CirculinearBoundary2D
Specified by:
clip in interface CirculinearContinuousCurve2D
Specified by:
clip in interface CirculinearCurve2D
Specified by:
clip in interface CirculinearElement2D
Specified by:
clip in interface ContinuousCirculinearCurve2D
Specified by:
clip in interface CircularShape2D
Specified by:
clip in interface Conic2D
Specified by:
clip in interface ContinuousCurve2D
Specified by:
clip in interface Curve2D
Specified by:
clip in interface SmoothCurve2D
Specified by:
clip in interface ContinuousOrientedCurve2D
Specified by:
clip in interface OrientedCurve2D
Specified by:
clip in interface SmoothOrientedCurve2D
Specified by:
clip in interface Shape2D
Overrides:
clip in class Ellipse2D
Parameters:
box - the clipping box
Returns:
the clipped shape

contains

public boolean contains(double x,
                        double y)
Return true if the point (x, y) lies exactly on the circle.

Specified by:
contains in interface Shape2D
Overrides:
contains in class Ellipse2D

appendPath

public GeneralPath appendPath(GeneralPath path)
Description copied from class: Ellipse2D
Add the path of the ellipse to the given path.

Specified by:
appendPath in interface ContinuousCurve2D
Overrides:
appendPath in class Ellipse2D
Parameters:
path - the path to be completed
Returns:
the completed path

draw

public void draw(Graphics2D g2)
Description copied from interface: Curve2D
Draws the curve on the given Graphics2D object.

Specified by:
draw in interface Curve2D
Specified by:
draw in interface Shape2D
Overrides:
draw in class Ellipse2D
Parameters:
g2 - the graphics to draw the curve

toString

public String toString()
Overrides:
toString in class Ellipse2D

equals

public boolean equals(Object obj)
Overrides:
equals in class Ellipse2D

clone

public Circle2D clone()
Description copied from interface: Curve2D
Overrides Object declaration to ensure Curve2D implementation are cloned as Curve2D.

Specified by:
clone in interface Curve2D
Overrides:
clone in class Ellipse2D
Returns:
the cloned curve


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.