src/bezier/util

Types

DeCasteljau {.byref.} = object
  points: seq[Vec2]
  originalLen: Positive
The results of a de Casteljau execution against a set of points

Procs

proc deCasteljau(points: openArray[Vec2]; t: float): DeCasteljau {....raises: [],
    tags: [].}
Uses de Casteljau's algorithm to determine the location of 't' on a curve
proc finalPoint(calculated: DeCasteljau): Vec2 {....raises: [], tags: [].}
Returns the caluclated result of running de Casteljau's algorithm
proc isOnLine(point, p1, p2: Vec2): bool {....raises: [], tags: [].}
proc linesIntersect(p1, p2, p3, p4: Vec2): Option[Vec2] {....raises: [], tags: [].}
Returns the point at which two lines intersect

Iterators

iterator forDistinct[T](input: seq[T]): T
Loops over the unique values in an input, assuming it has been pre-sorted
iterator left(calculated: DeCasteljau): Vec2 {....raises: [], tags: [].}
Yields the left-hand set of points for splitting a curve
iterator right(calculated: DeCasteljau): Vec2 {....raises: [], tags: [].}
Yields the right-hand set of points for splitting a curve
iterator roots(entries: seq[float]): float {....raises: [], tags: [].}
Calculate the roots of the given points
iterator roots[N: static[int]](entries: array[N, float]): float
Calculate the roots of the given points

Templates

template forIndexed(i, value, iter, exec: untyped)
template yieldAll(iter: untyped)