Class BSplineDouble<T extends VectorDouble<T>>
java.lang.Object
gaiasky.util.math.BSplineDouble<T>
- All Implemented Interfaces:
PathDouble<T>
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBSplineDouble(T[] controlPoints, boolean continuous) BSplineDouble(T[] controlPoints, int degree, boolean continuous) -
Method Summary
Modifier and TypeMethodDescriptiondoubleapproximate(T v) doubleapproximate(T in, int near) doubleapproximate(T in, int start, int count) doubleapproxLength(int samples) static <T extends VectorDouble<T>>
Tcalculate(T out, double t, T[] points, int degree, boolean continuous, T tmp) Calculates the n-degree b-spline value for the given position (t).static <T extends VectorDouble<T>>
Tcalculate(T out, int i, double 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 VectorDouble<T>>
Tcubic(T out, double t, T[] points, boolean continuous, T tmp) Calculates the cubic b-spline value for the given position (t).static <T extends VectorDouble<T>>
Tcubic(T out, int i, double 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 VectorDouble<T>>
Tcubic_derivative(T out, double t, T[] points, boolean continuous, T tmp) Calculates the cubic b-spline derivative for the given position (t).static <T extends VectorDouble<T>>
Tcubic_derivative(T out, int i, double 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 VectorDouble<T>>
Tderivative(T out, double t, T[] points, int degree, boolean continuous, T tmp) Calculates the n-degree b-spline derivative for the given position (t).static <T extends VectorDouble<T>>
Tderivative(T out, int i, double 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).derivativeAt(T out, double t) derivativeAt(T out, int span, double u) doubleintint
-
Field Details
-
controlPoints
-
knots
-
degree
public int degree -
continuous
public boolean continuous -
spanCount
public int spanCount
-
-
Constructor Details
-
BSplineDouble
public BSplineDouble() -
BSplineDouble
-
BSplineDouble
-
-
Method Details
-
cubic
public static <T extends VectorDouble<T>> T cubic(T out, double t, T[] points, boolean continuous, T tmp) Calculates the cubic b-spline value for the given position (t).- Parameters:
out- TheVectorDoubleto set to the result.t- The position ([0,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 VectorDouble<T>> T cubic_derivative(T out, double t, T[] points, boolean continuous, T tmp) Calculates the cubic b-spline derivative for the given position (t).- Parameters:
out- TheVectorDoubleto set to the result.t- The position ([0,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 VectorDouble<T>> T cubic(T out, int i, double 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- TheVectorDoubleto set to the result.i- The span ([0,spanCount]) spanCount = continuous ? points.length : points.length - 3 (cubic degree)u- The position ([0,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 VectorDouble<T>> T cubic_derivative(T out, int i, double 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- TheVectorDoubleto set to the result.i- The span ([0,spanCount]) spanCount = continuous ? points.length : points.length - 3 (cubic degree)u- The position ([0,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 VectorDouble<T>> T calculate(T out, double t, T[] points, int degree, boolean continuous, T tmp) Calculates the n-degree b-spline value for the given position (t).- Parameters:
out- TheVectorDoubleto set to the result.t- The position ([0,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 VectorDouble<T>> T derivative(T out, double t, T[] points, int degree, boolean continuous, T tmp) Calculates the n-degree b-spline derivative for the given position (t).- Parameters:
out- TheVectorDoubleto set to the result.t- The position ([0,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 VectorDouble<T>> T calculate(T out, int i, double 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- TheVectorDoubleto set to the result.i- The span ([0,spanCount]) spanCount = continuous ? points.length : points.length - degreeu- The position ([0,1]) on the spanpoints- 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 VectorDouble<T>> T derivative(T out, int i, double 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- TheVectorDoubleto set to the result.i- The span ([0,spanCount]) spanCount = continuous ? points.length : points.length - degreeu- The position ([0,1]) on the spanpoints- 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
-
set
-
valueAt
- Specified by:
valueAtin interfacePathDouble<T extends VectorDouble<T>>- Returns:
- The value of the path at t where 0≤t≤1
-
valueAt
-
derivativeAt
- Specified by:
derivativeAtin interfacePathDouble<T extends VectorDouble<T>>
-
derivativeAt
-
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:
approximatein interfacePathDouble<T extends VectorDouble<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
PathDouble.locate(Object)for a more precise (but more intensive) method.
-
approximate
-
approximate
-
locate
- Specified by:
locatein interfacePathDouble<T extends VectorDouble<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
PathDouble.approximate(Object)for a faster (but less precise) method.
-
approxLength
public double approxLength(int samples) - Specified by:
approxLengthin interfacePathDouble<T extends VectorDouble<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.
-