|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.util.Bezier
The class Bezier collects several useful
static mathematical functions related to Bezier curves.
All of the functions deal with control points that are
a single float number. In applications, these functions
would be used for each coordinate in a geometric point,
that is, for the x, y, and possibly z coordinates. Thus,
the functions would be used 2 or 3 times, once for each
coordinate in a 2 or 3 dimensional geometric point.
In Java Power Tools, these functions are used in class
PathList in the getShapePoint
method. This is one example of their usefulness.
One mathematical reference for this material is:
Gerald Farin
Curves and Surfaces for Computer Aided Geometric Design: A Practical Guide
Academic Press, 1988, ISBN 0-12-249050-9
Convention:
functions for float data are appended with
F and
functions for double data are appended with
D.
| Constructor Summary | |
Bezier()
|
|
| Method Summary | |
static double |
bezierD(double t,
double x0)
The trivial double Bezier polynomial of degree 0 that
returns x0. |
static double |
bezierD(double t,
double[] array,
int a,
int b)
This version of the Bezier polynomial uses the given polynomial parameter t, the given array of control points, and a pair of index values a and b with a <= b that define the range used in array for the computation; the function returns the Bezier for the given data. |
static double |
bezierD(double t,
double x0,
double x1)
The double Bezier polynomial of degree 1 that returns
the interpolation of x0 and x1 relative to t. |
static double |
bezierD(double t,
double x0,
double x1,
double x2)
The double Bezier polynomial of degree 2 that returns
the interpolation of the next pair of lower Bezier's relative to t. |
static double |
bezierD(double t,
double x0,
double x1,
double x2,
double x3)
The double Bezier polynomial of degree 3 that returns
the interpolation of the next pair of lower Bezier's relative to t. |
static float |
bezierF(float t,
float x0)
The trivial float Bezier polynomial of degree 0 that
returns x0. |
static float |
bezierF(float t,
float[] array,
int a,
int b)
This version of the Bezier polynomial uses the given polynomial parameter t, the given array of control points, and a pair of index values a and b with a <= b that define the range used in array for the computation; the function returns the Bezier for the given data. |
static float |
bezierF(float t,
float x0,
float x1)
The float Bezier polynomial of degree 1 that returns
the interpolation of x0 and x1 relative to t. |
static float |
bezierF(float t,
float x0,
float x1,
float x2)
The float Bezier polynomial of degree 2 that returns
the interpolation of the next pair of lower Bezier's relative to t. |
static float |
bezierF(float t,
float x0,
float x1,
float x2,
float x3)
The float Bezier polynomial of degree 3 that returns
the interpolation of the next pair of lower Bezier's relative to t. |
static double[] |
mapBezierD(double t,
double[] array)
This function maps the function BezierD of three
arguments across the given array and produces a new array with
size one less than the original array. |
static float[] |
mapBezierF(float t,
float[] array)
This function maps the function BezierF of three
arguments across the given array and produces a new array with
size one less than the original array. |
static double[] |
newBezierPointsD(double a,
double b,
double[] controls)
This function computes a new set of control points as if the Bezier polynomial defined by the given control points were to be viewed as on the sub-interval [a;b] of [0;1]. |
static float[] |
newBezierPointsF(float a,
float b,
float[] controls)
This function computes a new set of control points as if the Bezier polynomial defined by the given control points were to be viewed as on the sub-interval [a;b] of [0;1]. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Bezier()
| Method Detail |
public static float bezierF(float t,
float x0)
float Bezier polynomial of degree 0 that
returns x0.
t - the polynomial parameterx0 - control point 0
public static float bezierF(float t,
float x0,
float x1)
The float Bezier polynomial of degree 1 that returns
the interpolation of x0 and x1 relative to t.
In formulas, returns:
(1-t)*x0 + t*x1
The Bezier of degree 1 is used to compute points on a line.
t - the polynomial parameterx0 - control point 0x1 - control point 1
public static float bezierF(float t,
float x0,
float x1,
float x2)
The float Bezier polynomial of degree 2 that returns
the interpolation of the next pair of lower Bezier's relative to t.
In formulas, returns:
(1-t)*bezierF(t, x0, x1) + t*bezierF(t, x1, x2)
The Bezier of degree 2 is used to compute points on a quadratic Bezier curve.
t - the polynomial parameterx0 - control point 0x1 - control point 1x2 - control point 2
public static float bezierF(float t,
float x0,
float x1,
float x2,
float x3)
The float Bezier polynomial of degree 3 that returns
the interpolation of the next pair of lower Bezier's relative to t.
In formulas, returns:
(1-t)*bezierF(t, x0, x1, x2) + t*bezierF(t, x1, x2, x3)
The Bezier of degree 3 is used to compute points on a cubic Bezier curve.
t - the polynomial parameterx0 - control point 0x1 - control point 1x2 - control point 2x3 - control point 3
public static float bezierF(float t,
float[] array,
int a,
int b)
This version of the Bezier polynomial uses the given polynomial parameter t, the given array of control points, and a pair of index values a and b with a <= b that define the range used in array for the computation; the function returns the Bezier for the given data.
The precise preconditions are:
array is non-null0 <= a <= b < array.length
Returns 0 if the preconditions fail.
If a equals b, returns array[a] independent of t.
Otherwise, returns the following recursive value.
bezierF(t, bezierF(t,array,a,b-1), bezierF(t,array,a+1,b))
t - the polynomial parameterarray - the control point arraya - the start indexb - the final index
public static float[] mapBezierF(float t,
float[] array)
This function maps the function BezierF of three
arguments across the given array and produces a new array with
size one less than the original array.
First assume that the length N of the given array is at least 2 so the result array has length (N-1) that is at least 1. Then, the i-th entry in the result array is computed as follows:
bezierF(t, array[i], array[i+1])
If the given array has length 0 or 1, returns the trivial
array new float[0].
If the given array is null, then returns
null.
This is a helper method for the newBezierPointsF
method.
t - the interpolation parameterarray - the array to be mapped with bezierF
public static float[] newBezierPointsF(float a,
float b,
float[] controls)
This function computes a new set of control points as if the Bezier polynomial defined by the given control points were to be viewed as on the sub-interval [a;b] of [0;1].
This function is useful for finding the control points for a curve that is restricted to a sub-interval of its parameter space [0;1].
If a equals 0 and b equals 1 then returns a copy of the given control points (up to round off).
If b < a, the direction of the new Bezier is opposite to the original direction.
If a or b is outside of [0;1] then the result is correct but will involve more round off error since extrapolation is used.
This method implements the 1 dimensional heart of what is known as the generalized deCasteljau algorithm. See section 7.3 of the book by Farin mentioned in the introduction for details and a discussion of why the algorithm is correct.
a - float endpoint 1 in a sub-intervalb - float endpoint 2 in a sub-intervalcontrols - the original array of Bezier control points
public static double bezierD(double t,
double x0)
double Bezier polynomial of degree 0 that
returns x0.
t - the polynomial parameterx0 - control point 0
public static double bezierD(double t,
double x0,
double x1)
The double Bezier polynomial of degree 1 that returns
the interpolation of x0 and x1 relative to t.
In formulas, returns:
(1-t)*x0 + t*x1
The Bezier of degree 1 is used to compute points on a line.
t - the polynomial parameterx0 - control point 0x1 - control point 1
public static double bezierD(double t,
double x0,
double x1,
double x2)
The double Bezier polynomial of degree 2 that returns
the interpolation of the next pair of lower Bezier's relative to t.
In formulas, returns:
(1-t)*bezierF(t, x0, x1) + t*bezierF(t, x1, x2)
The Bezier of degree 2 is used to compute points on a quadratic Bezier curve.
t - the polynomial parameterx0 - control point 0x1 - control point 1x2 - control point 2
public static double bezierD(double t,
double x0,
double x1,
double x2,
double x3)
The double Bezier polynomial of degree 3 that returns
the interpolation of the next pair of lower Bezier's relative to t.
In formulas, returns:
(1-t)*bezierF(t, x0, x1, x2) + t*bezierF(t, x1, x2, x3)
The Bezier of degree 3 is used to compute points on a cubic Bezier curve.
t - the polynomial parameterx0 - control point 0x1 - control point 1x2 - control point 2x3 - control point 3
public static double bezierD(double t,
double[] array,
int a,
int b)
This version of the Bezier polynomial uses the given polynomial parameter t, the given array of control points, and a pair of index values a and b with a <= b that define the range used in array for the computation; the function returns the Bezier for the given data.
The precise preconditions are:
array is non-null0 <= a <= b < array.length
Returns 0 if the preconditions fail.
If a equals b, returns array[a] independent of t.
Otherwise, returns the following recursive value.
bezierD(t, bezierD(t,array,a,b-1), bezierD(t,array,a+1,b))
t - the polynomial parameterarray - the control point arraya - the start indexb - the final index
public static double[] mapBezierD(double t,
double[] array)
This function maps the function BezierD of three
arguments across the given array and produces a new array with
size one less than the original array.
First assume that the length N of the given array is at least 2 so the result array has length (N-1) that is at least 1. Then, the i-th entry in the result array is computed as follows:
bezierD(t, array[i], array[i+1])
If the given array has length 0 or 1, returns the trivial
array new double[0].
If the given array is null, then returns
null.
This is a helper method for the newBezierPointsD
method.
t - the interpolation parameterarray - the array to be mapped with bezierD
public static double[] newBezierPointsD(double a,
double b,
double[] controls)
This function computes a new set of control points as if the Bezier polynomial defined by the given control points were to be viewed as on the sub-interval [a;b] of [0;1].
This function is useful for finding the control points for a curve that is restricted to a sub-interval of its parameter space [0;1].
If a equals 0 and b equals 1 then returns a copy of the given control points (up to round off).
If b < a, the direction of the new Bezier is opposite to the original direction.
If a or b is outside of [0;1] then the result is correct but will involve more round off error since extrapolation is used.
This method implements the 1 dimensional heart of what is known as the generalized deCasteljau algorithm. See section 7.3 of the book by Farin mentioned in the introduction.
a - double endpoint 1 in a sub-intervalb - double endpoint 2 in a sub-intervalcontrols - the original array of Bezier control points
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||