com.partnersoft.geometry.xy
Class XyEllipse

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

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


Constructor Summary
XyEllipse(XyPoint center, double a, double b)
          Creates a new XyEllipse with the given center, horizontal radius (a), and vertical radius (b).
XyEllipse(XyPoint center, double a, double b, XyRotation rotation)
          Creates a new XyEllipse with the given center, horizontal radius (a), and vertical radius (b).
 
Method Summary
 boolean contains(XyPoint point)
          Tests if a point is inside this area.
static XyEllipse ellipse(XyRectangle rectangle)
          Creates a new XyEllipse bounded by the given XyRectangle.
 boolean equals(java.lang.Object nother)
           
 double getA()
          The a parameter, which is half the length of the major (longest) axis.
 double getArea()
          Returns the 2-dimensional area covered by this...
 double getB()
          The b parameter, which is half the length of the minor (shortest) axis.
 XyBounds getBounds()
          Returns an XyBounds object representing the rectangular extents of this shape.
 XyPoint getCenter()
          The center of the ellipse.
 double getEccentricity()
          The eccentricity of the ellipse.
 XyPoint getLeftFocus()
          The "left" focus.
 double getPerimeter()
          Returns the total length of the lines and/or curves bounding the area.
 XyPoint getRightFocus()
          The "right" focus.
 XyRotation getRotation()
          The angle of rotation of the major axis.
 java.util.Iterator<XyPoint> iterator()
           
 XyEllipse scaledBy(double factor)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 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 the ellipse to a polygon with the given number of vertices.
 java.lang.String toString()
           
 XyShape transformedBy(XyTransform transform)
          Transform the shape using the given transform.
 XyEllipse translatedBy(double offsetX, double offsetY)
          Translate the shape by adding all coordinates to the given x and y offsets.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XyEllipse

public XyEllipse(XyPoint center,
                 double a,
                 double b)
Creates a new XyEllipse with the given center, horizontal radius (a), and vertical radius (b). The ellipse will be aligned such that the horizontal radius is parallel to the X axis.


XyEllipse

public XyEllipse(XyPoint center,
                 double a,
                 double b,
                 XyRotation rotation)
Creates a new XyEllipse with the given center, horizontal radius (a), and vertical radius (b). The rotation rotates the ellipse relative to the x and y axes.

Method Detail

ellipse

public static XyEllipse ellipse(XyRectangle rectangle)
Creates a new XyEllipse bounded by the given XyRectangle.


toPolygon

public XyPolygon toPolygon(XyAngle granularity)
Converts the ellipse to a polygon with the given number of vertices.

Specified by:
toPolygon in interface XyArea<XyEllipse>

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<XyEllipse>

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<XyEllipse>
Parameters:
point - point to test for containment

getArea

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

Specified by:
getArea in interface XyArea<XyEllipse>
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<XyEllipse>
Returns:
geometric perimeter of this shape

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<XyEllipse>

scaledBy

public XyEllipse scaledBy(double factor)
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<XyEllipse>
Parameters:
factor - scaling factor
Returns:
scaled 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<XyEllipse>
Parameters:
transform - affine transform to apply.
Returns:
transformed result

translatedBy

public XyEllipse 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<XyEllipse>
Parameters:
offsetX - offset for the x dimension
offsetY - offset for the y dimension
Returns:
offset result

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

getA

public double getA()
The a parameter, which is half the length of the major (longest) axis.


getB

public double getB()
The b parameter, which is half the length of the minor (shortest) axis.


getRotation

public XyRotation getRotation()
The angle of rotation of the major axis.


getCenter

public XyPoint getCenter()
The center of the ellipse.


getEccentricity

public double getEccentricity()
The eccentricity of the ellipse.


getLeftFocus

public XyPoint getLeftFocus()
The "left" focus. Actual position is determined by rotation; this is the focus that if the ellipse were oriented with its major axis parallel to the X axis, its x would be less than that of the "right" focus.


getRightFocus

public XyPoint getRightFocus()
The "right" focus. Actual position is determined by rotation; this is the focus that if the ellipse were oriented with its major axis parallel to the X axis, its x would be greater than that of the "left" focus.