com.partnersoft.geometry.xy
Class XyCircle

java.lang.Object
  extended by com.partnersoft.geometry.xy.XyCircle
All Implemented Interfaces:
Immutable, XyArea<XyCircle>, XyShape<XyCircle>, java.lang.Iterable<XyPoint>

public class XyCircle
extends java.lang.Object
implements XyArea<XyCircle>

A circle in (x, y) space.

Copyright 2004-2007 Partner Software, Inc.

Version:
$Id: XyCircle.java 1704 2009-01-13 22:16:02Z paul $
Author:
Paul Reavis, Rich Stepanski, Richard Fay

Constructor Summary
XyCircle(double centerX, double centerY, double radius)
          Create a new circle with the given center and radius.
XyCircle(XyPoint center, double radius)
          Create a new circle with the given center and radius.
 
Method Summary
 boolean contains(XyPoint point)
          Tests if a point is inside this area.
 boolean equals(java.lang.Object nother)
           
static XyCircle forThreePoints(XyPoint p1, XyPoint p2, XyPoint p3)
          Calculates the circle that intersects the given three points.
 double getArea()
          Returns the 2-dimensional area covered by this...
 XyBounds getBounds()
          Returns an XyBounds object representing the rectangular extents of this shape.
 XyPoint getCenter()
          Geometric center of circle.
 double getPerimeter()
          Returns the total length of the lines and/or curves bounding the area.
 double getRadius()
          Radius of circle.
 java.util.Iterator<XyPoint> iterator()
           
 XyCircle scaledBy(double scale)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 XyCircle scaledBy(double scaleX, double scaleY)
           
 XyPolygon toPolygon()
          Same as XyArea.toPolygon(XyAngle) with a default angle granularity of 1/60 circle (1 degree, pi/30 radians).
 XyPolygon toPolygon(XyAngle granularity)
          Converts this area to a polygon which approximates it in some fashion.
 java.lang.String toString()
           
 XyShape transformedBy(XyTransform transform)
          Transform the shape using the given transform.
 XyCircle translatedBy(double offsetX, double offsetY)
          Translate the shape by adding all coordinates to the given x and y offsets.
 XyCircle withCenter(XyPoint newCenter)
          Returns a modified version of this circle with the given center.
 XyCircle withRadius(double newRadius)
          Returns a modified version of this circle with the given radius.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XyCircle

public XyCircle(double centerX,
                double centerY,
                double radius)
Create a new circle with the given center and radius.


XyCircle

public XyCircle(XyPoint center,
                double radius)
Create a new circle with the given center and radius.

Method Detail

forThreePoints

public static XyCircle forThreePoints(XyPoint p1,
                                      XyPoint p2,
                                      XyPoint p3)
Calculates the circle that intersects the given three points.


withRadius

public XyCircle withRadius(double newRadius)
Returns a modified version of this circle with the given radius.


withCenter

public XyCircle withCenter(XyPoint newCenter)
Returns a modified version of this circle with the given center.


scaledBy

public XyCircle scaledBy(double scale)
Description copied from interface: XyShape
Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions. This resulting shape must be of the same class as the original.

Specified by:
scaledBy in interface XyShape<XyCircle>
Parameters:
scale - scaling factor
Returns:
scaled result

scaledBy

public XyCircle scaledBy(double scaleX,
                         double scaleY)

translatedBy

public XyCircle translatedBy(double offsetX,
                             double offsetY)
Description copied from interface: XyShape
Translate the shape by adding all coordinates to the given x and y offsets. The resulting shape must be of the same class as the original.

Specified by:
translatedBy in interface XyShape<XyCircle>
Parameters:
offsetX - offset for the x dimension
offsetY - offset for the y dimension
Returns:
offset result

transformedBy

public XyShape transformedBy(XyTransform transform)
Description copied from interface: XyShape
Transform the shape using the given transform. Due to potential distortion the result may be a different type of shape than this one.

Specified by:
transformedBy in interface XyShape<XyCircle>
Parameters:
transform - affine transform to apply.
Returns:
transformed result

getBounds

public XyBounds getBounds()
Description copied from interface: XyShape
Returns an XyBounds object representing the rectangular extents of this shape.

Specified by:
getBounds in interface XyShape<XyCircle>

getArea

public double getArea()
Description copied from interface: XyArea
Returns the 2-dimensional area covered by this... area.

Specified by:
getArea in interface XyArea<XyCircle>
Returns:
geometric area of this shape

getPerimeter

public double getPerimeter()
Description copied from interface: XyArea
Returns the total length of the lines and/or curves bounding the area.

Specified by:
getPerimeter in interface XyArea<XyCircle>
Returns:
geometric perimeter of this shape

contains

public boolean contains(XyPoint point)
Description copied from interface: XyArea
Tests if a point is inside this area.

Specified by:
contains in interface XyArea<XyCircle>
Parameters:
point - point to test for containment

toPolygon

public XyPolygon toPolygon()
Description copied from interface: XyArea
Same as XyArea.toPolygon(XyAngle) with a default angle granularity of 1/60 circle (1 degree, pi/30 radians).

Specified by:
toPolygon in interface XyArea<XyCircle>

toPolygon

public XyPolygon toPolygon(XyAngle granularity)
Description copied from interface: XyArea
Converts this area to a polygon which approximates it in some fashion. For example, a circle can be converted to a polygon with enough sides to roughly approximate its shape. Areas consisting of linked line segments can be represented exactly.

The angle parameter allows a certain level of control of the output. Essentially it dictates the minimum angular granularity used to approximate curved paths. For example, a circle would be turned into a polygon by placing points around the circle, separated by the given angle.

Specified by:
toPolygon in interface XyArea<XyCircle>

iterator

public java.util.Iterator<XyPoint> iterator()
Specified by:
iterator in interface java.lang.Iterable<XyPoint>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

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

getCenter

public XyPoint getCenter()
Geometric center of circle.

Returns:
center of circle

getRadius

public double getRadius()
Radius of circle.

Returns:
radius of circle