APIdia Launch Partner
Top Fields Constructors Methods
com.badlogic.gdx.math

public Class BSpline<T extends Vector<T>>

extends Object
implements Path<T extends Vector<T>>
Class Inheritance
All Implemented Interfaces
com.badlogic.gdx.math.Path
Imports
com.badlogic.gdx.utils.Array

Author
Xoppa

Field Summary

Modifier and TypeField and Description
public boolean
public T[]
private static final float
public int
public Array<T>
public int
private T
private T
private T

Constructor Summary

AccessConstructor and Description
public
public
BSpline(final T[] controlPoints, final int degree, final boolean continuous)

Method Summary

Modifier and TypeMethod and Description
public float
public float
approximate(final T in, int start, final int count)

public float
approximate(final T in, final int near)

public float
public static <T extends Vector<T>> T

Returns:

The value of out
calculate
(final T
The Vector to set to the result.
out
,
final float
The position (0<=t<=1) on the spline
t
,
final T[]
The control points
points
,
final int
The degree of the b-spline
degree
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the n-degree b-spline value for the given position (t).

public static <T extends Vector<T>> T

Returns:

The value of out
calculate
(final T
The Vector to set to the result.
out
,
final int
The span (0<=ii, final float
The position (0<=u<=1) on the span
u
,
final T[]
The control points
points
,
final int
The degree of the b-spline, only 3 is supported
degree
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the n-degree b-spline value for the given span (i) at the given position (u).

public static <T extends Vector<T>> T

Returns:

The value of out
cubic
(final T
The Vector to set to the result.
out
,
final float
The position (0<=t<=1) on the spline
t
,
final T[]
The control points
points
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the cubic b-spline value for the given position (t).

public static <T extends Vector<T>> T

Returns:

The value of out
cubic
(final T
The Vector to set to the result.
out
,
final int
The span (0<=ii, final float
The position (0<=u<=1) on the span
u
,
final T[]
The control points
points
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the cubic b-spline value for the given span (i) at the given position (u).

public static <T extends Vector<T>> T

Returns:

The value of out
cubic_derivative
(final T
The Vector to set to the result.
out
,
final float
The position (0<=t<=1) on the spline
t
,
final T[]
The control points
points
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the cubic b-spline derivative for the given position (t).

public static <T extends Vector<T>> T

Returns:

The value of out
cubic_derivative
(final T
The Vector to set to the result.
out
,
final int
The span (0<=ii, final float
The position (0<=u<=1) on the span
u
,
final T[]
The control points
points
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the cubic b-spline derivative for the given span (i) at the given position (u).

public static <T extends Vector<T>> T

Returns:

The value of out
derivative
(final T
The Vector to set to the result.
out
,
final float
The position (0<=t<=1) on the spline
t
,
final T[]
The control points
points
,
final int
The degree of the b-spline
degree
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the n-degree b-spline derivative for the given position (t).

public static <T extends Vector<T>> T

Returns:

The value of out
derivative
(final T
The Vector to set to the result.
out
,
final int
The span (0<=ii, final float
The position (0<=u<=1) on the span
u
,
final T[]
The control points
points
,
final int
The degree of the b-spline, only 3 is supported
degree
,
final boolean
If true the b-spline restarts at 0 when reaching 1
continuous
,
final T
A temporary vector used for the calculation
tmp
)

Calculates the n-degree b-spline derivative for the given span (i) at the given position (u).

public T
derivativeAt(final T out, final float t)

Implements com.badlogic.gdx.math.Path.derivativeAt.

public T
derivativeAt(final T out, final int span, final float u)

Returns: The derivative of the spline at position u of the specified span

public float
public int
nearest(final T in)

Returns: The span closest to the specified value

public int
nearest(final T in, int start, final int count)

Returns: The span closest to the specified value, restricting to the specified spans.

public BSpline<T extends Vector<T>>
set(final T[] controlPoints, final int degree, final boolean continuous)

public T
valueAt(T out, float t)

Implements com.badlogic.gdx.math.Path.valueAt.

public T
valueAt(final T out, final int span, final float u)

Returns: The value of the spline at position u of the specified span

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

continuousback to summary
public boolean continuous
controlPointsback to summary
public T[] controlPoints
d6back to summary
private static final float d6
degreeback to summary
public int degree
knotsback to summary
public Array<T> knots
spanCountback to summary
public int spanCount
tmpback to summary
private T tmp
tmp2back to summary
private T tmp2
tmp3back to summary
private T tmp3

Constructor Detail

BSplineback to summary
public BSpline()
BSplineback to summary
public BSpline(final T[] controlPoints, final int degree, final boolean continuous)

Method Detail

approximateback to summary
public float approximate(T v)

Implements com.badlogic.gdx.math.Path.approximate.

Annotations
@Override
approximateback to summary
public float approximate(final T in, int start, final int count)
approximateback to summary
public float approximate(final T in, final int near)
approxLengthback to summary
public float approxLength(int samples)

Implements com.badlogic.gdx.math.Path.approxLength.

Annotations
@Override
calculateback to summary
public static <T extends Vector<T>> T calculate(final T out, final float t, final T[] points, final int degree, final boolean continuous, final T tmp)

Calculates the n-degree b-spline value for the given position (t).

Parameters
out:T

The Vector to set to the result.

t:float

The position (0<=t<=1) on the spline

points:T[]

The control points

degree:int

The degree of the b-spline

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

calculateback to summary
public static <T extends Vector<T>> T calculate(final T out, final int i, final float u, final T[] points, final int degree, final boolean continuous, final T tmp)

Calculates the n-degree b-spline value for the given span (i) at the given position (u).

Parameters
out:T

The Vector to set to the result.

i:int

The span (0<=iu:float

The position (0<=u<=1) on the span

points:T[]

The control points

degree:int

The degree of the b-spline, only 3 is supported

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

cubicback to summary
public static <T extends Vector<T>> T cubic(final T out, final float t, final T[] points, final boolean continuous, final T tmp)

Calculates the cubic b-spline value for the given position (t).

Parameters
out:T

The Vector to set to the result.

t:float

The position (0<=t<=1) on the spline

points:T[]

The control points

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

cubicback to summary
public static <T extends Vector<T>> T cubic(final T out, final int i, final float u, final T[] points, final boolean continuous, final T tmp)

Calculates the cubic b-spline value for the given span (i) at the given position (u).

Parameters
out:T

The Vector to set to the result.

i:int

The span (0<=iu:float

The position (0<=u<=1) on the span

points:T[]

The control points

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

cubic_derivativeback to summary
public static <T extends Vector<T>> T cubic_derivative(final T out, final float t, final T[] points, final boolean continuous, final T tmp)

Calculates the cubic b-spline derivative for the given position (t).

Parameters
out:T

The Vector to set to the result.

t:float

The position (0<=t<=1) on the spline

points:T[]

The control points

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

cubic_derivativeback to summary
public static <T extends Vector<T>> T cubic_derivative(final T out, final int i, final float u, final T[] points, final boolean continuous, final T tmp)

Calculates the cubic b-spline derivative for the given span (i) at the given position (u).

Parameters
out:T

The Vector to set to the result.

i:int

The span (0<=iu:float

The position (0<=u<=1) on the span

points:T[]

The control points

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

derivativeback to summary
public static <T extends Vector<T>> T derivative(final T out, final float t, final T[] points, final int degree, final boolean continuous, final T tmp)

Calculates the n-degree b-spline derivative for the given position (t).

Parameters
out:T

The Vector to set to the result.

t:float

The position (0<=t<=1) on the spline

points:T[]

The control points

degree:int

The degree of the b-spline

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

derivativeback to summary
public static <T extends Vector<T>> T derivative(final T out, final int i, final float u, final T[] points, final int degree, final boolean continuous, final T tmp)

Calculates the n-degree b-spline derivative for the given span (i) at the given position (u).

Parameters
out:T

The Vector to set to the result.

i:int

The span (0<=iu:float

The position (0<=u<=1) on the span

points:T[]

The control points

degree:int

The degree of the b-spline, only 3 is supported

continuous:boolean

If true the b-spline restarts at 0 when reaching 1

tmp:T

A temporary vector used for the calculation

Returns:T

The value of out

derivativeAtback to summary
public T derivativeAt(final T out, final float t)

Implements com.badlogic.gdx.math.Path.derivativeAt.

Annotations
@Override
derivativeAtback to summary
public T derivativeAt(final T out, final int span, final float u)
Returns:T

The derivative of the spline at position u of the specified span

locateback to summary
public float locate(T v)

Implements com.badlogic.gdx.math.Path.locate.

Annotations
@Override
nearestback to summary
public int nearest(final T in)
Returns:int

The span closest to the specified value

nearestback to summary
public int nearest(final T in, int start, final int count)
Returns:int

The span closest to the specified value, restricting to the specified spans.

setback to summary
public BSpline<T extends Vector<T>> set(final T[] controlPoints, final int degree, final boolean continuous)
valueAtback to summary
public T valueAt(T out, float t)

Implements com.badlogic.gdx.math.Path.valueAt.

Annotations
@Override
valueAtback to summary
public T valueAt(final T out, final int span, final float u)
Returns:T

The value of the spline at position u of the specified span