com.partnersoft.geometry.xy
Class XyQuadraticCurve

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

public class XyQuadraticCurve
extends java.lang.Object
implements XyPath<XyQuadraticCurve>

A quadratic curve, defined as P(t) = B(2,0)*CP + B(2,1)*P1 + B(2,2)*P2 over the interval 0 <= t <= 1.

Copyright 2007 Partner Software, inc.

Version:
$Id: XyQuadraticCurve.java 1195 2008-02-18 22:37:30Z paul $
Author:
Paul Reavis, Rich Stepanski, Richard Fay

Constructor Summary
XyQuadraticCurve(XyPoint startPoint, XyPoint endPoint, XyPoint controlPoint)
          Creates a new quadratic curve with the given start, end, and control points.
 
Method Summary
 XyBounds getBounds()
          Returns an XyBounds object representing the rectangular extents of this shape.
 XyPoint getControlPoint()
           
 XyPoint getEndPoint()
          Returns the last point in the shape.
 double getLength()
          Returns the length of the path.
 XyPoint getStartPoint()
          Returns the first point in the shape.
 java.util.Iterator<XyPoint> iterator()
           
 XyQuadraticCurve scaledBy(double factor)
          Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions.
 XyPolyline toPolyline()
          Same as XyPath.toPolyline(XyAngle) with a default angle granularity of 1/60 circle (6 degrees, pi/30 radians).
 XyPolyline toPolyline(XyAngle granularity)
          Converts this area to a polyline which approximates it in some fashion.
 XyShape transformedBy(XyTransform transform)
          Transform the shape using the given transform.
 XyQuadraticCurve 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, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XyQuadraticCurve

public XyQuadraticCurve(XyPoint startPoint,
                        XyPoint endPoint,
                        XyPoint controlPoint)
Creates a new quadratic curve with the given start, end, and control points.

Method Detail

getLength

public double getLength()
Description copied from interface: XyPath
Returns the length of the path.

Specified by:
getLength in interface XyPath<XyQuadraticCurve>
Returns:
geometric length of this shape

getStartPoint

public XyPoint getStartPoint()
Description copied from interface: XyPath
Returns the first point in the shape.

Specified by:
getStartPoint in interface XyPath<XyQuadraticCurve>

getEndPoint

public XyPoint getEndPoint()
Description copied from interface: XyPath
Returns the last point in the shape.

Specified by:
getEndPoint in interface XyPath<XyQuadraticCurve>

toPolyline

public XyPolyline toPolyline()
Description copied from interface: XyPath
Same as XyPath.toPolyline(XyAngle) with a default angle granularity of 1/60 circle (6 degrees, pi/30 radians).

Specified by:
toPolyline in interface XyPath<XyQuadraticCurve>

toPolyline

public XyPolyline toPolyline(XyAngle granularity)
Description copied from interface: XyPath
Converts this area to a polyline which approximates it in some fashion. For example, a curve can be converted to a polyline with enough segments to roughly approximate its shape. Paths 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, an arc would be turned into a polyline by placing points around the arc's slice of a circle, separated by the given angle.

Specified by:
toPolyline in interface XyPath<XyQuadraticCurve>

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

scaledBy

public XyQuadraticCurve 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<XyQuadraticCurve>
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<XyQuadraticCurve>
Parameters:
transform - affine transform to apply.
Returns:
transformed result

translatedBy

public XyQuadraticCurve 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<XyQuadraticCurve>
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>

getControlPoint

public XyPoint getControlPoint()