org.robokind.api.interpolation.cspline
Class CSplineInterpolator

java.lang.Object
  extended by org.robokind.api.interpolation.cspline.CSplineInterpolator
All Implemented Interfaces:
Interpolator

public class CSplineInterpolator
extends Object
implements Interpolator

Implementation of a Catmull-Rom Cardinal Spline using reflected endpoints. A Cardinal Spline represents the natural curve of a rope under tension. A Catmull-Rom Spline is a Cardinal spline with a fixed tension of T=0.5. The standard c-spline has hidden endpoints which influence the curvature of the first and last segment. Instead of having them user defined, the reflected endpoints method is used. Hidden points as reflections around the first and last point are added as a simple heuristic for good continuity.

Author:
Matthew Stevenson

Field Summary
static org.robokind.api.common.config.VersionProperty VERSION
          Interpolator VersionProperty.
static String VERSION_NAME
          Interpolator version name.
static String VERSION_NUMBER
          Interpolator version number.
 
Constructor Summary
CSplineInterpolator()
          Creates an empty CSplineInterpolator.
 
Method Summary
 Point2D addPoint(double x, double y)
          Adds a new Point with the given x and y value.
 void addPoints(int i, List<Point2D> points)
          Adds a List of Point at the given index.
 void addPoints(List<Point2D> points)
          Adds a List of Points.
 void clear()
          Clears all the Points from the Interpolator.
 List<Point2D> getControlPoints()
          Returns a list of the Interpolator's points.
 List<Point2D> getInterpolatedPoints()
          Returns a List of Points interpolated from the Interpolator's control points.
 org.robokind.api.common.config.VersionProperty getInterpolatorVersion()
          Return the Interpolator's VersionProperty.
 Point2D insertPoint(int i, double x, double y)
          Adds a new point at the given index.
 boolean interpolationChanged()
          Returns true if the List of interpolated Points has changed since last being requested and needs to be recalculated.
 Point2D removePoint(int i)
          Remove the Point at the given index.
 void removePoint(Point2D p)
          Removes the given Point from the Interpolator.
 Point2D setPoint(int i, double x, double y)
          Sets the x and y values of the Point at the given index.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION_NAME

public static final String VERSION_NAME
Interpolator version name.

See Also:
Constant Field Values

VERSION_NUMBER

public static final String VERSION_NUMBER
Interpolator version number.

See Also:
Constant Field Values

VERSION

public static final org.robokind.api.common.config.VersionProperty VERSION
Interpolator VersionProperty.

Constructor Detail

CSplineInterpolator

public CSplineInterpolator()
Creates an empty CSplineInterpolator.

Method Detail

addPoint

public Point2D addPoint(double x,
                        double y)
Description copied from interface: Interpolator
Adds a new Point with the given x and y value.

Specified by:
addPoint in interface Interpolator
Parameters:
x - x-value to add
y - y-value to add
Returns:
the Point which was added

insertPoint

public Point2D insertPoint(int i,
                           double x,
                           double y)
Description copied from interface: Interpolator
Adds a new point at the given index.

Specified by:
insertPoint in interface Interpolator
Parameters:
i - index for where to add the new Point
x - x-value to add
y - y-value to add
Returns:
the Point which was added

addPoints

public void addPoints(List<Point2D> points)
Description copied from interface: Interpolator
Adds a List of Points.

Specified by:
addPoints in interface Interpolator
Parameters:
points - List of Points to add

addPoints

public void addPoints(int i,
                      List<Point2D> points)
Description copied from interface: Interpolator
Adds a List of Point at the given index.

Specified by:
addPoints in interface Interpolator
Parameters:
i - index for where to add the Points
points - List of Points to add

setPoint

public Point2D setPoint(int i,
                        double x,
                        double y)
Description copied from interface: Interpolator
Sets the x and y values of the Point at the given index.

Specified by:
setPoint in interface Interpolator
Parameters:
i - index of the point to set
x - x-value to set
y - y-value to set
Returns:
the Point after being set

removePoint

public void removePoint(Point2D p)
Description copied from interface: Interpolator
Removes the given Point from the Interpolator.

Specified by:
removePoint in interface Interpolator
Parameters:
p - the Point to remove

removePoint

public Point2D removePoint(int i)
Description copied from interface: Interpolator
Remove the Point at the given index.

Specified by:
removePoint in interface Interpolator
Parameters:
i - index of the Point to remove
Returns:
the Point removed

getControlPoints

public List<Point2D> getControlPoints()
Description copied from interface: Interpolator
Returns a list of the Interpolator's points.

Specified by:
getControlPoints in interface Interpolator
Returns:
list of the Interpolator's points

getInterpolatedPoints

public List<Point2D> getInterpolatedPoints()
Description copied from interface: Interpolator
Returns a List of Points interpolated from the Interpolator's control points.

Specified by:
getInterpolatedPoints in interface Interpolator
Returns:
List of Points interpolated from the Interpolator's control points

interpolationChanged

public boolean interpolationChanged()
Description copied from interface: Interpolator
Returns true if the List of interpolated Points has changed since last being requested and needs to be recalculated.

Specified by:
interpolationChanged in interface Interpolator
Returns:
true if the List of interpolated Points has changed since last being requested and needs to be recalculated

clear

public void clear()
Description copied from interface: Interpolator
Clears all the Points from the Interpolator.

Specified by:
clear in interface Interpolator

getInterpolatorVersion

public org.robokind.api.common.config.VersionProperty getInterpolatorVersion()
Description copied from interface: Interpolator
Return the Interpolator's VersionProperty. Used to specify an Interpolator type when serializing and de-serializing an Interpolator.

Specified by:
getInterpolatorVersion in interface Interpolator
Returns:
Interpolator's VersionProperty


Copyright © 2011. All Rights Reserved.