math.geom2d.conic
Class Circle2D

java.lang.Object
  extended by math.geom2d.conic.Ellipse2D
      extended by math.geom2d.conic.Circle2D
All Implemented Interfaces:
java.awt.Shape, Conic2D, Boundary2D, ContinuousBoundary2D, ContinuousCurve2D, ContinuousOrientedCurve2D, Curve2D, OrientedCurve2D, SmoothCurve2D, SmoothOrientedCurve2D, Shape2D

public class Circle2D
extends Ellipse2D

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

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.conic.Conic2D
CIRCLE, ELLIPSE, HYPERBOLA, NOT_A_CONIC, PARABOLA, POINT, STRAIGHT_LINE, TWO_LINES
 
Fields inherited from interface math.geom2d.curve.ContinuousCurve2D
CLOSED_EDGE, LOOP, OPEN_EDGE
 
Fields inherited from interface math.geom2d.Shape2D
ACCURACY, defaultClipWindow, EMPTY_SET
 
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 and radius
Circle2D(Point2D center, double radius)
          Create a new circle with specified point center and radius
 
Method Summary
 java.awt.geom.GeneralPath appendPath(java.awt.geom.GeneralPath path)
          Add the path of the ellipse to the given path.
 CurveSet2D<? extends SmoothOrientedCurve2D> clip(Box2D box)
          Clip the circle by a box.
 boolean contains(double x, double y)
          Return true if the point (x, y) lies exactly on the circle.
 boolean equals(java.lang.Object obj)
           
 java.awt.Rectangle getBounds()
          Return bounding box of the circle.
 java.awt.geom.Rectangle2D getBounds2D()
          Return more precise bounds of the circle.
 double[] getCartesianEquation()
          return 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.
 int getConicType()
           
 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. fillable) shape.
 double getDistance(java.awt.geom.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, whihc 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.
protected  java.awt.geom.GeneralPath getGeneralPath()
           
 java.util.Collection<Point2D> getIntersections(StraightObject2D 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 getLength1()
          Returns the length of the first semi-axis of the ellipse.
 double getLength2()
          Returns the length of the second semi-axis of the ellipse.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
          Return pathiterator for this circle.
 java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans, double flatness)
          Return pathiterator for this circle.
 Point2D getPoint(double t)
          Get the position of the curve from internal parametric representation, depending on the parameter t.
 Point2D getPoint(double t, Point2D point)
          Get the position of the curve from internal parametric representation, depending on the parameter t.
 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(java.awt.geom.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.
 CircleArc2D getSubCurve(double t0, double t1)
          return a new CircleArc2D. t0 and t1 are position on circle.
 Vector2D getTangent(double t)
           
 boolean isCircle()
           
 boolean isDegenerated()
           
 boolean isEllipse()
           
 boolean isHyperbola()
           
 boolean isParabola()
           
 boolean isPoint()
           
 boolean isStraightLine()
           
 boolean isTwoLines()
           
 void setCircle(double xc, double yc, double r)
           
 void setCircle(Point2D center, double r)
           
 void setRadius(double radius)
           
 
Methods inherited from class math.geom2d.conic.Ellipse2D
contains, contains, contains, getAngle, getAsPolyline, getBoundaryCurves, getBoundingBox, getCenter, getContinuousCurves, getCurvature, getProjectedPoint, getProjectedVector, getRho, getSmoothPieces, getT0, getT1, getVector1, getVector2, getWindingAngle, intersects, intersects, isBounded, isClosed, isDirect, isInside, project, setCenter, setCenter, setEllipse, setEllipse, setEllipse, setEllipse, toString, transform
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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(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 and radius

Method Detail

getLength

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


getRadius

public double getRadius()

setRadius

public void setRadius(double radius)

setCircle

public void setCircle(double xc,
                      double yc,
                      double r)

setCircle

public void setCircle(Point2D center,
                      double r)

getConicType

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

isEllipse

public boolean isEllipse()
Overrides:
isEllipse in class Ellipse2D

isParabola

public boolean isParabola()
Overrides:
isParabola in class Ellipse2D

isHyperbola

public boolean isHyperbola()
Overrides:
isHyperbola in class Ellipse2D

isCircle

public boolean isCircle()
Overrides:
isCircle in class Ellipse2D

isStraightLine

public boolean isStraightLine()
Overrides:
isStraightLine in class Ellipse2D

isTwoLines

public boolean isTwoLines()
Overrides:
isTwoLines in class Ellipse2D

isPoint

public boolean isPoint()
Overrides:
isPoint in class Ellipse2D

isDegenerated

public boolean isDegenerated()
Overrides:
isDegenerated in class Ellipse2D

getCartesianEquation

public double[] getCartesianEquation()
return 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:
getCartesianEquation in interface Conic2D
Overrides:
getCartesianEquation in class Ellipse2D

getLength1

public double getLength1()
Returns the length of the first semi-axis of the ellipse.

Overrides:
getLength1 in class Ellipse2D

getLength2

public double getLength2()
Returns the length of the second semi-axis of the ellipse.

Overrides:
getLength2 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, whihc 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

getTangent

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

getSignedDistance

public double getSignedDistance(java.awt.geom.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

getPoint

public Point2D getPoint(double t,
                        Point2D point)
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 Conic2D
Specified by:
getReverseCurve in interface Boundary2D
Specified by:
getReverseCurve in interface ContinuousBoundary2D
Specified by:
getReverseCurve in interface ContinuousCurve2D
Specified by:
getReverseCurve in interface ContinuousOrientedCurve2D
Specified by:
getReverseCurve in interface Curve2D
Specified by:
getReverseCurve in interface OrientedCurve2D
Specified by:
getReverseCurve in interface SmoothCurve2D
Specified by:
getReverseCurve in interface SmoothOrientedCurve2D
Overrides:
getReverseCurve in class Ellipse2D

getSubCurve

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

Specified by:
getSubCurve in interface ContinuousCurve2D
Specified by:
getSubCurve in interface ContinuousOrientedCurve2D
Specified by:
getSubCurve in interface Curve2D
Specified by:
getSubCurve in interface SmoothCurve2D
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.

getDistance

public double getDistance(java.awt.geom.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 java.util.Collection<Point2D> getIntersections(StraightObject2D line)
Compute intersections of the circle with a line. Return an array of Point2D, of size 0, 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 SmoothOrientedCurve2D> 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 Conic2D
Specified by:
clip in interface ContinuousCurve2D
Specified by:
clip in interface ContinuousOrientedCurve2D
Specified by:
clip in interface Curve2D
Specified by:
clip in interface OrientedCurve2D
Specified by:
clip in interface SmoothCurve2D
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 java.awt.Shape
Overrides:
contains in class Ellipse2D

getBounds

public java.awt.Rectangle getBounds()
Return bounding box of the circle.

Specified by:
getBounds in interface java.awt.Shape
Overrides:
getBounds in class Ellipse2D

getBounds2D

public java.awt.geom.Rectangle2D getBounds2D()
Return more precise bounds of the circle.

Specified by:
getBounds2D in interface java.awt.Shape
Overrides:
getBounds2D in class Ellipse2D

appendPath

public java.awt.geom.GeneralPath appendPath(java.awt.geom.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

getGeneralPath

protected java.awt.geom.GeneralPath getGeneralPath()
Overrides:
getGeneralPath in class Ellipse2D

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans)
Return pathiterator for this circle.

Specified by:
getPathIterator in interface java.awt.Shape
Overrides:
getPathIterator in class Ellipse2D

getPathIterator

public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform trans,
                                                  double flatness)
Return pathiterator for this circle.

Specified by:
getPathIterator in interface java.awt.Shape
Overrides:
getPathIterator in class Ellipse2D

equals

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