Package com.badlogic.gdx.math
Class BSpline<T extends Vector<T>>
- java.lang.Object
-
- com.badlogic.gdx.math.BSpline<T>
-
-
Field Summary
Fields Modifier and Type Field Description booleancontinuousT[]controlPointsintdegreeArray<T>knotsintspanCount
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description floatapproximate(T v)floatapproximate(T in, int near)floatapproximate(T in, int start, int count)floatapproxLength(int samples)static <T extends Vector<T>>
Tcalculate(T out, float t, T[] points, int degree, boolean continuous, T tmp)Calculates the n-degree b-spline value for the given position (t).static <T extends Vector<T>>
Tcalculate(T out, int i, float u, T[] points, int degree, boolean continuous, T tmp)Calculates the n-degree b-spline value for the given span (i) at the given position (u).static <T extends Vector<T>>
Tcubic(T out, float t, T[] points, boolean continuous, T tmp)Calculates the cubic b-spline value for the given position (t).static <T extends Vector<T>>
Tcubic(T out, int i, float u, T[] points, boolean continuous, T tmp)Calculates the cubic b-spline value for the given span (i) at the given position (u).static <T extends Vector<T>>
Tcubic_derivative(T out, float t, T[] points, boolean continuous, T tmp)Calculates the cubic b-spline derivative for the given position (t).static <T extends Vector<T>>
Tcubic_derivative(T out, int i, float u, T[] points, boolean continuous, T tmp)Calculates the cubic b-spline derivative for the given span (i) at the given position (u).static <T extends Vector<T>>
Tderivative(T out, float t, T[] points, int degree, boolean continuous, T tmp)Calculates the n-degree b-spline derivative for the given position (t).static <T extends Vector<T>>
Tderivative(T out, int i, float u, T[] points, int degree, boolean continuous, T tmp)Calculates the n-degree b-spline derivative for the given span (i) at the given position (u).TderivativeAt(T out, float t)TderivativeAt(T out, int span, float u)floatlocate(T v)intnearest(T in)intnearest(T in, int start, int count)BSplineset(T[] controlPoints, int degree, boolean continuous)TvalueAt(T out, float t)TvalueAt(T out, int span, float u)
-
-
-
Constructor Detail
-
BSpline
public BSpline()
-
BSpline
public BSpline(T[] controlPoints, int degree, boolean continuous)
-
-
Method Detail
-
cubic
public static <T extends Vector<T>> T cubic(T out, float t, T[] points, boolean continuous, T tmp)
Calculates the cubic b-spline value for the given position (t).- Parameters:
out- The Vector to set to the result.t- The position (0<=t<=1) on the splinepoints- The control pointscontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
cubic_derivative
public static <T extends Vector<T>> T cubic_derivative(T out, float t, T[] points, boolean continuous, T tmp)
Calculates the cubic b-spline derivative for the given position (t).- Parameters:
out- The Vector to set to the result.t- The position (0<=t<=1) on the splinepoints- The control pointscontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
cubic
public static <T extends Vector<T>> T cubic(T out, int i, float u, T[] points, boolean continuous, T tmp)
Calculates the cubic b-spline value for the given span (i) at the given position (u).- Parameters:
out- The Vector to set to the result.i- The span (0<=iu- The position (0<=u<=1) on the spanpoints- The control pointscontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
cubic_derivative
public static <T extends Vector<T>> T cubic_derivative(T out, int i, float u, T[] points, boolean continuous, T tmp)
Calculates the cubic b-spline derivative for the given span (i) at the given position (u).- Parameters:
out- The Vector to set to the result.i- The span (0<=iu- The position (0<=u<=1) on the spanpoints- The control pointscontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
calculate
public static <T extends Vector<T>> T calculate(T out, float t, T[] points, int degree, boolean continuous, T tmp)
Calculates the n-degree b-spline value for the given position (t).- Parameters:
out- The Vector to set to the result.t- The position (0<=t<=1) on the splinepoints- The control pointsdegree- The degree of the b-splinecontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
derivative
public static <T extends Vector<T>> T derivative(T out, float t, T[] points, int degree, boolean continuous, T tmp)
Calculates the n-degree b-spline derivative for the given position (t).- Parameters:
out- The Vector to set to the result.t- The position (0<=t<=1) on the splinepoints- The control pointsdegree- The degree of the b-splinecontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
calculate
public static <T extends Vector<T>> T calculate(T out, int i, float u, T[] points, int degree, boolean continuous, T tmp)
Calculates the n-degree b-spline value for the given span (i) at the given position (u).- Parameters:
out- The Vector to set to the result.i- The span (0<=iu- The position (0<=u<=1) on the spanpoints- The control pointsdegree- The degree of the b-spline, only 3 is supportedcontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
derivative
public static <T extends Vector<T>> T derivative(T out, int i, float u, T[] points, int degree, boolean continuous, T tmp)
Calculates the n-degree b-spline derivative for the given span (i) at the given position (u).- Parameters:
out- The Vector to set to the result.i- The span (0<=iu- The position (0<=u<=1) on the spanpoints- The control pointsdegree- The degree of the b-spline, only 3 is supportedcontinuous- If true the b-spline restarts at 0 when reaching 1tmp- A temporary vector used for the calculation- Returns:
- The value of out
-
valueAt
public T valueAt(T out, int span, float u)
- Returns:
- The value of the spline at position u of the specified span
-
derivativeAt
public T derivativeAt(T out, float t)
- Specified by:
derivativeAtin interfacePath<T extends Vector<T>>
-
derivativeAt
public T derivativeAt(T out, int span, float u)
- Returns:
- The derivative of the spline at position u of the specified span
-
nearest
public int nearest(T in)
- Returns:
- The span closest to the specified value
-
nearest
public int nearest(T in, int start, int count)
- Returns:
- The span closest to the specified value, restricting to the specified spans.
-
approximate
public float approximate(T v)
- Specified by:
approximatein interfacePath<T extends Vector<T>>- Returns:
- The approximated value (between 0 and 1) on the path which is closest to the specified value. Note that the
implementation of this method might be optimized for speed against precision, see
Path.locate(Object)for a more precise (but more intensive) method.
-
approximate
public float approximate(T in, int start, int count)
-
approximate
public float approximate(T in, int near)
-
locate
public float locate(T v)
-
approxLength
public float approxLength(int samples)
- Specified by:
approxLengthin interfacePath<T extends Vector<T>>- Parameters:
samples- The amount of divisions used to approximate length. Higher values will produce more precise results, but will be more CPU intensive.- Returns:
- An approximated length of the spline through sampling the curve and accumulating the euclidean distances between the sample points.
-
-