Skip to content

Collection of Bifrost compounds to work with curves inside of Bifrost.

License

Notifications You must be signed in to change notification settings

domrab/Bifrost_dhCurves

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Bifrost_dhCurves

Collection of Bifrost compounds to work with curves inside of Bifrost. bSplines should match Maya NURBS curves for the most part.
To install, follow the instructions here.

bSpline_nodes Update 1: bSpline_nodes2


construct_bSpline

Construct a bSpline object from it's control points, the degree, and optionally a knot vector.

Inputs

control_points [in]
The input control points for bSpline.

degree [in]
The degree.

knots [in] (optional)
The knot vector. This is optional. If nothing is provided, a default knot vector gets assigned.

remap_range [in]
If no knot vector is supplied, the default range is 0 to spans. If remap_range is true, the min and max input values get used.

min [in]
Default start value for generated knot vector if it's not supplied.

max [in]
Default end value for generated knot vector if it's not supplied.

Outputs

bSpline [out]
The resulting bSpline object.


knot_vector

Construct a knot vector with the proper multiplicity.

Inputs

cv_count [in]
The number of cvs for which this knot vector will be used.

degree [in]
The degree of the bSpline (determines the multiplicity).

remap_range [in]
The default range is 0 to spans. If remap_range is true, the min and max input values get used.

min [in]
Default start value for generated knot vector if it's not supplied.

max [in]
Default end value for generated knot vector if it's not supplied.

Outputs

knots [out]
The output knot vector


parameter_array

Similar to the native sequence_array node but instead of a start and step size, this takes creates size samples between start and end inclusive.

Inputs

size [in]
The number of parameters.

start [in]
The first value in the parameter array.

end [in]
The last value in the parameter array.

Outputs

parameters [out]
The parameter array.


bSpline_scope

An easy visualization compound for bSplines.

Note

It appears for a zero-degree bSpline the visualization is off. As far as I understand, a p=0 bSpline is stepped. Given the visualization through one strand connecting all the CVs, the stepping will be invisible as the actual bSpline parameters are all lying on the points themselves. Thus a zero-degree bSpline visualized will look like a first-degree bSpline.

Inputs

bSpline [in]
The bSpline to visualize.

steps_per_span [in]
The number of sample steps per span. Maya's nurbs equivalent of this is 4 or 16 depending if subdivision preview is turned on.

color [in]
The visualization color.

shape [in]
The shape, this corresponds to the shape on the strand shape.

thickness [in]
The thickness of the shape, only applicable when shape is tube.

screen_aligned [in]
If the shape is screen aligned, only applicable when shape is tube.

Outputs

strands [out]
The strands created from the bSpline for visualization purposes.


get_d1_bSpline_length (internal)

Calculate the accurate length of a degree 1 bSpline curve

Inputs

bSpline [in]
The bSpline to get the length from.

custom_range [in]
If true, the length is calculated on a subsection of the curve.

min [in]
The start parameter of the sub curve.

max [in]
The end parameter of the sub curve.

Outputs

length [out]
The accurate length.

sample_positions [out]
The sampled positions used to calculate the length.


get_dN_bSpline_length (internal)

Calculate the approximate length of a bSpline of any degree.

Inputs

bSpline [in]
The bSpline to get the length from.

steps [in]
The total number of substeps used to estimate the length.

custom_range [in]
If true, the length is calculated on a subsection of the curve.

min [in]
The start parameter of the sub curve.

max [in]
The end parameter of the sub curve.

Outputs

length [out]
The approximate length.

sample_positions [out]
The sampled positions used to calculate the length.


get_bSpline_length

Get the length of a given (sub) bSpline. The result will be accurate for a degree 1 spline but always smaller than the real length for any bSpline of degree greater than 1.

Inputs

bSpline [in]
The bSpline to get the length from.

custom_range [in]
If true, the length is calculated on a subsection of the curve.

min [in]
The start parameter of the sub curve.

max [in]
The end parameter of the sub curve.

steps [in]
The total number of substeps used to estimate the length.

color [in]
The visualization color.

shape [in]
The shape, this corresponds to the shape on the strand shape.

thickness [in]
The thickness of the shape, only applicable when shape is tube.

screen_aligned [in]
If the shape is screen aligned, only applicable when shape is tube.

Outputs

length [out]
The approximate length.

strands [out]
The strands created from the bSpline for visualization purposes.


deconstruct_bSpline

Deconstruct a bSpline into it's components.

Inputs

bSpline [in]
The bSpline to query.

Outputs

cvs [out]
The control points.

cv_count [out]
The control point count.

degree [out]
The degree.

knots [out]
The knot vector.

min [out]
The minimum value in the knot vector.

max [out]
The maximum value in the knot vector.


get_bSpline_cvs

Get control point info from a bSpline.

Inputs

bSpline [in]
The bSpline to query.

Outputs

cvs [out]
The control points.

cv_count [out]
The control point count.


get_bSpline_degree

Get the degree info from a bSpline.

Inputs

bSpline [in]
The bSpline to query.

Outputs

degree [out]
The degree.


get_bSpline_knots

Get the knot vector info from a bSpline.

Inputs

bSpline [in]
The bSpline to query.

Outputs

knots [out]
The knot vector.

min [out]
The minimum value in the knot vector.

max [out]
The maximum value in the knot vector.


deBoor (internal)

Simple deBoor implementation to sample a bSpline. While slower than the matrix representation of bSplines, I found this to produce an output matching Maya NURBS curves.

Inputs

c__cvs [in]
The control point array.

p__degree [in]
The degree of the curve.

t__knots [in]
The knot vector.

x__parameter [in]
The parameter to query at.

k__span [in]
The span in which the parameter lies.

Outputs

position [out]
The calculated output position.


find_span (internal)

Find the span for the deBoor algorithm from a given parameter and the knot vector.

Inputs

parameter [in]
The parameter to find the span for.

knots [in]
The knot vector of the bSpline.

Outputs

parameter_clamped [out]
The parameter clamped in the valid knot vector range.

span [out]
The span in which the parameter lies.


sample_bSpline

Sample a bSpline at a given parameter

Inputs

bSpline [in]
The bSpline to query.

parameter [in]
The parameter to sample the bSpline at.

Outputs

position [out]
The sampled position.


sample_bSpline_per_span

Sample a bSpline several times at each span at equally spaced parameter intervals.

Inputs

bSpline [in]
The bSpline to query.

steps [in]
The number of parameter steps per span.

Outputs

positions [out]
The sampled positions.

parameters [out]
The parameters at which the positions got sampled.


reparameterize_bSpline

Reparameterize a given bSpline.

Inputs

bSpline [in]
The bSpline to resample.

samples [in]
The number of samples per span. This uses sample_bSpline_per_span under the hood.

degree [in]
The desired output degree. As a higher order bSpline tends to shift 'inwards' of the CVs and the CVs get sampled on the existing bSpline, a higher number of samples is required to maintain the shape as best as possible.

remap_range [in]
If false, the range of the input bSpline is used. If remap_range is true, the min and max input values get used.

min [in]
Start value for new bSpline.

max [in]
End value for new bSpline.

Outputs

new_bSpline [out]
The reparameterized bSpline.


compute_bSpline_derivative

Compute the n-th derivative of a given bSpline.

Inputs

bSpline [in]
The bSpline to compute the derivative of. Must be at least first-degree.

order [in]
The n-th order derivative. This value internally gets clamped between 1 and bSpline.degree.

Outputs

derivative_bSpline [out]
The derivative bSpline.

derivative_cvs [out]
The derivative control points.

derivative_degree [out]
The derivative degree.

derivative_knots [out]
The derivative knots.


measure_linear_curve

Utility to measure the distances along a linear curve (array of 3D points).

Inputs

control_points [in]
The control points.

Outputs

lengths [out]
An array containing the length of each segment.

cumulative [out]
An array containing the cumulative length for each segment.

total [out]
The total length of the curve (equivalent to the last value in cumulative).


bSpline_parameter_scope

For easy visualization of parameters on a bSpline.

Inputs

bSpline [in]
The bSpline to sample the parameters on.

parameters [in]
The parameters to sample.

color [in]
The visualization color.

shape [in]
This corresponds to the shape on the point shape. Do not use numeric as I did not provide a way to specify the property name.

size [in]
The size of the shape. Not applicable when shape is point.

screen_aligned [in]
If the shape is screen aligned. Not applicable when shape is point.

Outputs

points [out]
The points created for visualization purposes.


matrix_from_bSplines

Given a main and up bSpline curves and a parameter, this calculates a no-scale, no-shear matrix. Currently limited to +X pointing towards the increasing parameter value and +Y to the sampled location on the up curve.

Inputs

bSpline_main [in]
The main curve.

bSpline_up [in]
The up curve. The CVs and the degree of this node get used together with the min/max knot values from bSpline_main to construct a curve that has the same valid sample space.

parameters [in]
The parameter at which both bSplines get sampled.

Outputs

matrix [out]
The output matrix.

About

Collection of Bifrost compounds to work with curves inside of Bifrost.

Topics

Resources

License

Stars

Watchers

Forks