MCPcopy
hub / github.com/CadQuery/cadquery / nbCurve

Function nbCurve

cadquery/occ_impl/nurbs.py:607–663  ·  view source on GitHub ↗

NURBS book A3.1 with modifications to handle periodicity. Parameters ---------- u : Array Parameter values. order : int B-spline order. knots : Array Knot vector. pts : Array Control points. periodic : bool, optional Periodici

(
    u: Array, order: int, knots: Array, pts: Array, periodic: bool = False
)

Source from the content-addressed store, hash-verified

605
606@njit
607def nbCurve(
608 u: Array, order: int, knots: Array, pts: Array, periodic: bool = False
609) -> Array:
610 """
611 NURBS book A3.1 with modifications to handle periodicity.
612
613 Parameters
614 ----------
615 u : Array
616 Parameter values.
617 order : int
618 B-spline order.
619 knots : Array
620 Knot vector.
621 pts : Array
622 Control points.
623 periodic : bool, optional
624 Periodicity flag. The default is False.
625
626 Returns
627 -------
628 Array
629 Curve values.
630
631 """
632
633 # number of control points
634 nb = pts.shape[0]
635
636 u_, knots_ext, minspan, maxspan, deltaspan = _preprocess(u, order, knots, periodic)
637
638 # number of param values
639 nu = np.size(u)
640
641 # chunk size
642 n = order + 1
643
644 # temp chunk storage
645 temp = np.zeros(n)
646
647 # initialize
648 out = np.zeros((nu, 3))
649
650 for i in range(nu):
651 ui = u_[i]
652
653 # find span
654 span = nbFindSpan(ui, order, knots, minspan, maxspan) + deltaspan
655
656 # evaluate chunk
657 nbBasis(span, ui, order, knots_ext, temp)
658
659 # multiply by ctrl points
660 for j in range(order + 1):
661 out[i, :] += temp[j] * pts[(span - order + int(periodic) + j) % nb, :]
662
663 return out
664

Callers 1

__call__Method · 0.85

Calls 4

_preprocessFunction · 0.85
nbFindSpanFunction · 0.85
nbBasisFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected