hmi.math
Class BSpline2f

java.lang.Object
  extended by hmi.math.BSpline2f

public class BSpline2f
extends Object

\class BSpline2f \brief Two-dimensional bezier curve. The Bspline offers a precalculated bezier curve with a given amount of segments. Providing an offset value between 0.0 ~ 1.0 the 2 dimensional coordinate is provided.

Author:
Niels Nijdam

Field Summary
private  float[] a
           
private  float[] b
           
private  float[] controlPoint1A
           
private  float[] controlPoint2A
           
private  float[] controlPoints
           
private  int offsetControlPoints
           
private  int offsetPoints
           
private  float[] points
           
private  int segments
           
private  float[] xCoords
           
private  float[] yCoords
           
 
Constructor Summary
BSpline2f()
           
BSpline2f(BSpline2f bSpline2f)
          The copy constructor.
BSpline2f(float[] points, int offsetPoints, float[] controlPoints, int offsetControlPoints, int segments)
           
 
Method Summary
 void calculateSpline()
          \brief calculates an internal set of coordinates (segments) An internal representation of the Bezier curve.
 float[] getControlPoint1A()
          \brief returns absolute position of control point 1.
 float getControlPoint1X()
           
 float getControlPoint1Y()
           
 float[] getControlPoint2A()
          \brief returns absolute position of controlpoint2.
 float getControlPoint2X()
           
 float getControlPoint2Y()
           
 float[] getControlPoints()
           
 int getOffsetControlPoints()
           
 int getOffsetPoints()
           
 float getPoint1X()
           
 float getPoint1Y()
           
 float getPoint2X()
           
 float getPoint2Y()
           
 float[] getPoints()
           
 int getSegments()
          \brief returns the amount of line segments.
 float[] getSplineCoord(float offset)
          \brief calculate a point on the BSpline.
 void getSplineCoord(float offset, float[] target2f)
          \brief calculate a point on the BSpline.
 float[] getXCoords()
          \brief returns the array containing the x values from the precalculated Bezier curve (array size == segments).
 float[] getYCoords()
          \brief returns the array containing the y values from the precalculated Bezier curve (array size == segments).
 void setControlPoint1X(float value)
           
 void setControlPoint1Y(float value)
           
 void setControlPoint2X(float value)
           
 void setControlPoint2Y(float value)
           
 void setControlPoints(float[] controlPoints)
           
 void setOffsetControlPoints(int offsetControlPoints)
           
 void setOffsetPoints(int offsetPoints)
           
 void setPoint1X(float value)
           
 void setPoint1Y(float value)
           
 void setPoint2X(float value)
           
 void setPoint2Y(float value)
           
 void setPoints(float[] points)
           
 void setSegments(int segments)
           
 void updateAbsolute()
          \brief updates the absolute positions of the control points.
 void updateBSpline()
          \brief precalculate bspline algorithm variables.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

points

private float[] points

offsetPoints

private int offsetPoints

controlPoints

private float[] controlPoints

offsetControlPoints

private int offsetControlPoints

controlPoint1A

private final float[] controlPoint1A

controlPoint2A

private final float[] controlPoint2A

a

private final float[] a

b

private final float[] b

segments

private int segments

xCoords

private float[] xCoords

yCoords

private float[] yCoords
Constructor Detail

BSpline2f

public BSpline2f()

BSpline2f

public BSpline2f(float[] points,
                 int offsetPoints,
                 float[] controlPoints,
                 int offsetControlPoints,
                 int segments)

BSpline2f

public BSpline2f(BSpline2f bSpline2f)
The copy constructor. \brief creates a copy. \param bSpline2f the curve to be copied.

Method Detail

updateBSpline

public void updateBSpline()
\brief precalculate bspline algorithm variables. Recalculate certain algorithm computations which don't need to be recalculated everytime. Only when changing one or more of the four points, this method needs to be invoked. Note that if you are using the precalculated spline, it needs also to be recalculated. Most of the time whenever you change a coordinate perform a updateBSpline(); calculateSpline();


calculateSpline

public void calculateSpline()
\brief calculates an internal set of coordinates (segments) An internal representation of the Bezier curve. The detail quality of the curve is given by the amount of line segments.


getSplineCoord

public float[] getSplineCoord(float offset)
\brief calculate a point on the BSpline. \param offset an offset in the range 0.0 ~ 1.0 (0.0 = point1 and 1.0 = point2). \return The coordinates on the Bezier curve at the given offset. Used for dynamic retrival of a coordinate on the curve.


getSplineCoord

public void getSplineCoord(float offset,
                           float[] target2f)
\brief calculate a point on the BSpline. \param offset an offset in the range 0.0 ~ 1.0 (0.0 = point1 and 1.0 = point2). \param target2f the target array where the new values need to be stored into. Used for dynamic retrival of a coordinate on the curve.


updateAbsolute

public void updateAbsolute()
\brief updates the absolute positions of the control points. \param offset an offset in the range 0.0 ~ 1.0 (0.0 = point1 and 1.0 = point2). \param target2f the target array where the new values need to be stored into. Used for dynamic retrival of a coordinate on the curve.


getControlPoint1A

public float[] getControlPoint1A()
\brief returns absolute position of control point 1. \return the absolute coordinate control point 1.


getControlPoint2A

public float[] getControlPoint2A()
\brief returns absolute position of controlpoint2. \return the absolute coordinate controlpoint2.


getSegments

public int getSegments()
\brief returns the amount of line segments. \return the amount of line segments.


getXCoords

public float[] getXCoords()
\brief returns the array containing the x values from the precalculated Bezier curve (array size == segments). \return array containing x coordinate values.


getYCoords

public float[] getYCoords()
\brief returns the array containing the y values from the precalculated Bezier curve (array size == segments). \return array containing y coordinate values.


getPoints

public float[] getPoints()

setPoints

public void setPoints(float[] points)

getOffsetPoints

public int getOffsetPoints()

setOffsetPoints

public void setOffsetPoints(int offsetPoints)

getControlPoints

public float[] getControlPoints()

setControlPoints

public void setControlPoints(float[] controlPoints)

getOffsetControlPoints

public int getOffsetControlPoints()

setOffsetControlPoints

public void setOffsetControlPoints(int offsetControlPoints)

setSegments

public void setSegments(int segments)

getPoint1X

public float getPoint1X()

getPoint1Y

public float getPoint1Y()

getPoint2X

public float getPoint2X()

getPoint2Y

public float getPoint2Y()

getControlPoint1X

public float getControlPoint1X()

getControlPoint1Y

public float getControlPoint1Y()

getControlPoint2X

public float getControlPoint2X()

getControlPoint2Y

public float getControlPoint2Y()

setPoint1X

public void setPoint1X(float value)

setPoint1Y

public void setPoint1Y(float value)

setPoint2X

public void setPoint2X(float value)

setPoint2Y

public void setPoint2Y(float value)

setControlPoint1X

public void setControlPoint1X(float value)

setControlPoint1Y

public void setControlPoint1Y(float value)

setControlPoint2X

public void setControlPoint2X(float value)

setControlPoint2Y

public void setControlPoint2Y(float value)