MCPcopy Index your code
hub / github.com/CadQuery/cadquery / nbFindSpan

Function nbFindSpan

cadquery/occ_impl/nurbs.py:407–453  ·  view source on GitHub ↗

NURBS book A2.1 with modifications to handle periodic usecases. Parameters ---------- u : float Parameter value. order : int Spline order. knots : ndarray Knot vector. Returns ------- Span index.

(
    u: float,
    order: int,
    knots: Array,
    low: Optional[int] = None,
    high: Optional[int] = None,
)

Source from the content-addressed store, hash-verified

405
406@njiti
407def nbFindSpan(
408 u: float,
409 order: int,
410 knots: Array,
411 low: Optional[int] = None,
412 high: Optional[int] = None,
413) -> int:
414 """
415 NURBS book A2.1 with modifications to handle periodic usecases.
416
417 Parameters
418 ----------
419 u : float
420 Parameter value.
421 order : int
422 Spline order.
423 knots : ndarray
424 Knot vector.
425
426 Returns
427 -------
428 Span index.
429
430 """
431
432 if low is None:
433 low = order
434
435 if high is None:
436 high = knots.shape[0] - order - 1
437
438 mid = (low + high) // 2
439
440 if u >= knots[-1]:
441 return high - 1 # handle last span
442 elif u < knots[0]:
443 return low
444
445 while u < knots[mid] or u >= knots[mid + 1]:
446 if u < knots[mid]:
447 high = mid
448 else:
449 low = mid
450
451 mid = (low + high) // 2
452
453 return mid
454
455
456@njiti

Callers 10

test_derFunction · 0.90
nbCurveFunction · 0.85
nbCurveDerFunction · 0.85
nbSurfaceFunction · 0.85
nbSurfaceDerFunction · 0.85
designMatrixFunction · 0.85
designMatrix2DFunction · 0.85
derMatrixFunction · 0.85
periodicDerMatrixFunction · 0.85
penaltyMatrix2DFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_derFunction · 0.72