Curves

Curves can be refined, splitted, knots can be removed, and the degree can be manipulated.


Refining a Curve

Based on the principles of knot insertion, a single knot can be inserted multiple times into a curve (without changing the points the curve describes) by the insertKnot function.

NCurve2 = insertKnot(NCurve, 0.75, 2) # insert knot at 0.75 twice
C2 = NCurve2(evalpoints)

plotCurve3D(C2, controlPoints=NCurve2.controlPoints)
[ Info: The knot vector is being modified (normalized).

Several knots can be inserted by the refine function.

NCurve2 = refine(NCurve, [0.1, 0.2, 0.3, 0.8221]) # insert the array of knots
C2 = NCurve2(evalpoints)

plotCurve3D(C2, controlPoints=NCurve2.controlPoints)
Note

Refining a curve does not change the points in space described by the curve. Effectively, in the plots it can be seen that the number of control points is increased. However, also underlying properties such as the differentiability are changed.


Splitting a Curve

To split a curve into multiple separate curves the function split is provided which returns an array of curves.

cVec = split(NCurve, [0.2, 0.5]) # split at 0.2 and 0.5

# plot all three curves
data = PlotlyJS.GenericTrace[]
for (i, spC) in enumerate(cVec)
    push!(data, plotCurve3D(spC(evalpoints), returnTrace=true, controlPoints=spC.controlPoints)...)
end
PlotlyJS.plot(data)

To equally split a curve into $n$ curves as a second argument an integer can be provided:

cVec = split(NCurve, 4) # split into 4 curves
4-element Vector{NURBScurve{Float64}}:
 NURBScurve{Float64}(NURB{Float64}(3, [0.0, 0.0, 0.0, 0.0, 0.6666666666666666, 1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0]), StaticArraysCore.SVector{3, Float64}[[0.0, 0.0, 0.0], [0.1, 0.25, 0.0], [0.2125, 0.2875, 0.0], [0.259375, 0.37187500000000007, 0.0], [0.27239583333333334, 0.3963541666666668, 0.0]])
 NURBScurve{Float64}(NURB{Float64}(3, [0.0, 0.0, 0.0, 0.0, 0.33333333333333326, 1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0]), StaticArraysCore.SVector{3, Float64}[[0.27239583333333334, 0.3963541666666668, 0.0], [0.28541666666666665, 0.4208333333333334, 0.0], [0.31666666666666665, 0.4833333333333333, 0.0], [0.3666666666666667, 0.43333333333333335, 0.0], [0.41666666666666674, 0.4, 0.0]])
 NURBScurve{Float64}(NURB{Float64}(3, [0.0, 0.0, 0.0, 0.0, 0.6666666666666665, 1.0, 1.0, 1.0, 1.0], [1.0, 1.0, 1.0, 1.75, 1.9375]), StaticArraysCore.SVector{3, Float64}[[0.41666666666666674, 0.4, 0.0], [0.4666666666666667, 0.3666666666666667, 0.0], [0.5666666666666667, 0.31666666666666665, 0.0], [0.7238095238095238, 0.5595238095238094, 0.6428571428571427], [0.7494623655913979, 0.5930107526881719, 0.7258064516129032]])
 NURBScurve{Float64}(NURB{Float64}(3, [0.0, 0.0, 0.0, 0.0, 0.3333333333333335, 1.0, 1.0, 1.0, 1.0], [1.9375, 2.125, 2.5, 1.0, 1.0]), StaticArraysCore.SVector{3, Float64}[[0.7494623655913979, 0.5930107526881719, 0.7258064516129032], [0.7705882352941178, 0.6205882352941176, 0.7941176470588235], [0.8200000000000001, 0.6699999999999999, 0.9], [1.0, 0.4, 0.0], [1.1, 0.4, 0.0]])

Removing Knots from a Curve

Based on the principles of knot removal, an interior knot can potentially be removed multiple times from a curve (without changing the points the curve describes) by the removeKnot function.

p = 3

P1 = SVector(0.0, 0.0, 1.0)
P2 = SVector(0.0, 2.0, 0.0)
P3 = SVector(1.5, 3.0, 0.0)
P4 = SVector(3.0, 3.0, 0.0)
P5 = SVector(4.5, 3.0, 0.0)
P6 = SVector(6.0, 2.0, 0.0)
P7 = SVector(6.0, 0.0, 1.0)

cP = [P1, P2, P3, P4, P5, P6, P7]

kVec = Float64[0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2]

BCurve1 = BsplineCurve(Bspline(p, kVec), cP)
C1 = BCurve1(evalpoints)

BCurve2 = removeKnot(BCurve1, 0.5, 2) # remove knot at 0.5 twice
C2 = BCurve2(evalpoints)

# --- plot both curves
t1 = plotCurve3D(C1, controlPoints=BCurve1.controlPoints, returnTrace=true)
t2 = plotCurve3D(C2, controlPoints=BCurve2.controlPoints, returnTrace=true)

fig = make_subplots(
    rows=1, cols=2,
    specs=fill(Spec(kind="scene"), 1, 2)
)

add_trace!(fig, t1[1], row=1, col=1)
add_trace!(fig, t1[2], row=1, col=1)
add_trace!(fig, t2[1], row=1, col=2)
add_trace!(fig, t2[2], row=1, col=2)
fig
[ Info: The knot vector is being modified (normalized).
Note

Removing a knot from a curve is only possible when the continuity of the curve is sufficient at the knot. A central part of the removeKnot function is to verify if the knot can actually be removed. If not, warnings are generated, indicating the encountered limitations.


Degree Manipulation

To be done.