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,
)
| 405 | |
| 406 | @njiti |
| 407 | def 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 |
no outgoing calls