Spline curves

class splinebox.spline_curves.Spline(M, basis_function, closed=False, coeffs=None)

Base class for the construction of a spline.

Parameters

Mint

Number of control points.

basis_functionsplinebox.basis_functions.BasisFunction

The basis function used to construct the spline.

closedboolean

Whether or not the spline is closed, i.e. the two ends connect.

arcLength(t0, tf=None)

Integrate along the arc length.

Can probably be made faster if the basis functions accept arrays directly.

Parameters

t0float

Start point in parameter space.

tffloat (optional)

End point in parameter space.

property basis_function
centroid()

Does this correspond to the geometric centroid? Probably not, since the coefficient values are used. Why is centroid always 2D? Should there be a check for dimensionality here?

property coeffs
copy()
draw(dimensions)

Computes a whether a point is inside or outside a closed spline on a regular grid of points.

I would ask the user to provide a grid of points directly instead of asking for the dimensions. Like that the user can choose how densly they want to sample the grid.

eval(t, derivative=0)

Evalute the spline or one of its derivatives at parameter value(s) t.

Parameters

tnumpy.array, float

A 1D numpy array or a single float value.

derivativeint

Can be 0, 1, 2 for the spline, and its first and second derivative respectively.

getCoefsFromDenseContour(contourPoints, arcLengthParameterization=False)

???

Fits the spline to match a contour. get is a bad name since nothing is returned. fit would be better. Presumably the this is different from getCoefsFromKnots because the spline does not have to go through the points.

getCoefsFromKnots(knots)

???

Fits the spline to go through the knots. get is a bad name since nothing is returned. fit would be better.

getKnotsFromCoefs()
isInside(point)

Determines if a point is inside the closed spline or not. Is it fair game to change the coeff of the object or should it be cloned first? The splinebox.splines.Spline.translate() method should be used instead of subtracting the point.

Parameters

point : numpy.array

lengthToParameter(s)

Convert the arc length s to the coresponding value in parameter space.

Parameters

sfloat

Length on curve.

lengthToParameterRecursion(s, currentValue, lowerBound, upperBound, precisionDecimals=4)

Convert the given arc length s on the curve to a value in parameters space. This is done recursively, i.e. check if the point is before or after halfway and repeat.

Some intelegent default can probably be set so the user only has to provide s. Or this function should be made private entirely, because there is splinebox.splines.Spline.lengthToParameter()

Parameters

sfloat

Arc length on the spline.

currentValuefloat

The arc length to the lower bound.

lowerBoundfloat

Lower limit in parameter space.

upperBoundfloat

Upper limit in parameters space.

precisionDecimalsint

Precision to which the length is matched.

rotate(rotationMatrix)

Rotate the spline. Should the dimensionality be checked here?

sampleArcLength(numSamples, dt=False)

Evaluate the spline equidistantly spaced along its trajectory. Perhaps it makes sense to ask the user to provide an array of distances instead of the numSamples.

scale(scalingFactor)

Enlarge or shrink the spline. This should probably use splinebox.splines.Spline.translate() scalingFactor can be renamed to factor.

translate(translationVector)

Translates the spline by a vector. Is vector the right name here or can it also be a scalar?

windingNumber(t)

???

Number that can be integrated along the entire spline to determine where it wraps around the origin or not.

class splinebox.spline_curves.HermiteSpline(M, basis_function, closed=False, coeffs=None, tangents=None)

Class for the construction of a Hermite spline.

Parameters

Mint

Number of control points.

basis_functionsplinebox.basis_functions.BasisFunction

The basis function used to construct the spline.

closedboolean

Whether or not the spline is closed, i.e. the two ends connect.