libgdx API

## Class Bezier<T extends Vector<T>>

• java.lang.Object
• All Implemented Interfaces:
Path<T>

public class Bezier<T extends Vector<T>>
extends java.lang.Object
implements Path<T>
Implementation of the Bezier curve.
Author:
Xoppa
• ### Field Summary

Fields
Modifier and Type Field and Description
Array<T> points
• ### Constructor Summary

Constructors
Constructor and Description
Bezier()
Bezier(Array<T> points, int offset, int length)
Bezier(T... points)
Bezier(T[] points, int offset, int length)
• ### Method Summary

All Methods
Modifier and Type Method and Description
float approximate(T v)
float approxLength(int samples)
static <T extends Vector<T>>
T
cubic_derivative(T out, float t, T p0, T p1, T p2, T p3, T tmp)
Cubic Bezier curve derivative
static <T extends Vector<T>>
T
cubic(T out, float t, T p0, T p1, T p2, T p3, T tmp)
Cubic Bezier curve
T derivativeAt(T out, float t)
static <T extends Vector<T>>
T
linear_derivative(T out, float t, T p0, T p1, T tmp)
Simple linear interpolation derivative
static <T extends Vector<T>>
T
linear(T out, float t, T p0, T p1, T tmp)
Simple linear interpolation
float locate(T v)
static <T extends Vector<T>>
T
quadratic_derivative(T out, float t, T p0, T p1, T p2, T tmp)
static <T extends Vector<T>>
T
quadratic(T out, float t, T p0, T p1, T p2, T tmp)
Bezier set(Array<T> points, int offset, int length)
Bezier set(T... points)
Bezier set(T[] points, int offset, int length)
T valueAt(T out, float t)
• ### Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
• ### Field Detail

• #### points

public Array<T extends Vector<T>> points
• ### Constructor Detail

• #### Bezier

public Bezier()
• #### Bezier

public Bezier(T... points)
• #### Bezier

public Bezier(T[] points,
int offset,
int length)
• #### Bezier

public Bezier(Array<T> points,
int offset,
int length)
• ### Method Detail

• #### linear

public static <T extends Vector<T>> T linear(T out,
float t,
T p0,
T p1,
T tmp)
Simple linear interpolation
Parameters:
out - The Vector to set to the result.
t - The location (ranging 0..1) on the line.
p0 - The start point.
p1 - The end point.
tmp - A temporary vector to be used by the calculation.
Returns:
The value specified by out for chaining
• #### linear_derivative

public static <T extends Vector<T>> T linear_derivative(T out,
float t,
T p0,
T p1,
T tmp)
Simple linear interpolation derivative
Parameters:
out - The Vector to set to the result.
t - The location (ranging 0..1) on the line.
p0 - The start point.
p1 - The end point.
tmp - A temporary vector to be used by the calculation.
Returns:
The value specified by out for chaining

public static <T extends Vector<T>> T quadratic(T out,
float t,
T p0,
T p1,
T p2,
T tmp)
Parameters:
out - The Vector to set to the result.
t - The location (ranging 0..1) on the curve.
p0 - The first bezier point.
p1 - The second bezier point.
p2 - The third bezier point.
tmp - A temporary vector to be used by the calculation.
Returns:
The value specified by out for chaining

public static <T extends Vector<T>> T quadratic_derivative(T out,
float t,
T p0,
T p1,
T p2,
T tmp)
Parameters:
out - The Vector to set to the result.
t - The location (ranging 0..1) on the curve.
p0 - The first bezier point.
p1 - The second bezier point.
p2 - The third bezier point.
tmp - A temporary vector to be used by the calculation.
Returns:
The value specified by out for chaining
• #### cubic

public static <T extends Vector<T>> T cubic(T out,
float t,
T p0,
T p1,
T p2,
T p3,
T tmp)
Cubic Bezier curve
Parameters:
out - The Vector to set to the result.
t - The location (ranging 0..1) on the curve.
p0 - The first bezier point.
p1 - The second bezier point.
p2 - The third bezier point.
p3 - The fourth bezier point.
tmp - A temporary vector to be used by the calculation.
Returns:
The value specified by out for chaining
• #### cubic_derivative

public static <T extends Vector<T>> T cubic_derivative(T out,
float t,
T p0,
T p1,
T p2,
T p3,
T tmp)
Cubic Bezier curve derivative
Parameters:
out - The Vector to set to the result.
t - The location (ranging 0..1) on the curve.
p0 - The first bezier point.
p1 - The second bezier point.
p2 - The third bezier point.
p3 - The fourth bezier point.
tmp - A temporary vector to be used by the calculation.
Returns:
The value specified by out for chaining
• #### set

public Bezier set(T... points)
• #### set

public Bezier set(T[] points,
int offset,
int length)
• #### set

public Bezier set(Array<T> points,
int offset,
int length)
• #### valueAt

public T valueAt(T out,
float t)
Specified by:
valueAt in interface Path<T extends Vector<T>>
Returns:
The value of the path at t where 0<=t<=1
• #### derivativeAt

public T derivativeAt(T out,
float t)
Specified by:
derivativeAt in interface Path<T extends Vector<T>>
• #### approximate

public float approximate(T v)
Specified by:
approximate in interface Path<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.
• #### locate

public float locate(T v)
Specified by:
locate in interface Path<T extends Vector<T>>
Returns:
The precise location (between 0 and 1) on the path which is closest to the specified value. Note that the implementation of this method might be CPU intensive, see Path.approximate(Object) for a faster (but less precise) method.
• #### approxLength

public float approxLength(int samples)
Specified by:
approxLength in interface Path<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.