Package gaiasky.util.math
Class CatmullRomSplined<T extends Vectord<T>>
java.lang.Object
gaiasky.util.math.CatmullRomSplined<T>
- All Implemented Interfaces:
Pathd<T>
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
approximate
(T v) double
approximate
(T in, int near) double
approximate
(T in, int start, int count) double
approxLength
(int samples) static <T extends Vectord<T>>
Tcalculate
(T out, double t, T[] points, boolean continuous, T tmp) Calculates the catmullrom value for the given position (t).static <T extends Vectord<T>>
Tcalculate
(T out, int i, double u, T[] points, boolean continuous, T tmp) Calculates the catmullrom value for the given span (i) at the given position (u).static <T extends Vectord<T>>
Tderivative
(T out, double t, T[] points, boolean continuous, T tmp) Calculates the derivative of the catmullrom spline for the given position (t).static <T extends Vectord<T>>
Tderivative
(T out, int i, double u, T[] points, boolean continuous, T tmp) Calculates the derivative of the catmullrom spline for the given span (i) at the given position (u).derivativeAt
(T out, double t) derivativeAt
(T out, int span, double u) double
int
int
-
Field Details
-
controlPoints
-
continuous
public boolean continuous -
spanCount
public int spanCount
-
-
Constructor Details
-
CatmullRomSplined
public CatmullRomSplined() -
CatmullRomSplined
-
-
Method Details
-
calculate
public static <T extends Vectord<T>> T calculate(T out, double t, T[] points, boolean continuous, T tmp) Calculates the catmullrom value for the given position (t).- Parameters:
out
- The Vectord to set to the result.t
- The position (0invalid input: '<'=tinvalid input: '<'=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
-
calculate
public static <T extends Vectord<T>> T calculate(T out, int i, double u, T[] points, boolean continuous, T tmp) Calculates the catmullrom value for the given span (i) at the given position (u).- Parameters:
out
- The Vectord to set to the result.i
- The span (0invalid input: '<'=iinvalid input: '<'spanCount) spanCount = continuous ? points.length : points.length - degreeu
- The position (0invalid input: '<'=uinvalid input: '<'=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
-
derivative
public static <T extends Vectord<T>> T derivative(T out, double t, T[] points, boolean continuous, T tmp) Calculates the derivative of the catmullrom spline for the given position (t).- Parameters:
out
- The Vectord to set to the result.t
- The position (0invalid input: '<'=tinvalid input: '<'=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
-
derivative
public static <T extends Vectord<T>> T derivative(T out, int i, double u, T[] points, boolean continuous, T tmp) Calculates the derivative of the catmullrom spline for the given span (i) at the given position (u).- Parameters:
out
- The Vectord to set to the result.i
- The span (0invalid input: '<'=iinvalid input: '<'spanCount) spanCount = continuous ? points.length : points.length - degreeu
- The position (0invalid input: '<'=uinvalid input: '<'=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
-
set
-
valueAt
-
valueAt
- Returns:
- The value of the spline at position u of the specified span
-
derivativeAt
- Specified by:
derivativeAt
in interfacePathd<T extends Vectord<T>>
-
derivativeAt
- Returns:
- The derivative of the spline at position u of the specified span
-
nearest
- Returns:
- The span closest to the specified value
-
nearest
- Returns:
- The span closest to the specified value, restricting to the specified spans.
-
approximate
- Specified by:
approximate
in interfacePathd<T extends Vectord<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
Pathd.locate(Object)
for a more precise (but more intensive) method.
-
approximate
-
approximate
-
locate
- Specified by:
locate
in interfacePathd<T extends Vectord<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
Pathd.approximate(Object)
for a faster (but less precise) method.
-
approxLength
public double approxLength(int samples) - Specified by:
approxLength
in interfacePathd<T extends Vectord<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.
-