# Eval

`verb.eval.Eval`

**CLASS**

`Eval`

provides all of the core algorithms for evaluating points and derivatives on NURBS curves and surfaces. Most of the
time, it makes more sense to use the tools in verb.geom for this, but in some cases this will make more sense.

Eval also provides experimental tools for evaluating points in NURBS volumes.

Many of these algorithms owe their implementation to Piegl & Tiller's "The NURBS Book"

## rationalCurveTangent

**STATIC METHOD**

`rationalCurveTangent(curve : NurbsCurveData, u : Float) : Array<Float>`

Compute the tangent at a point on a NURBS curve

**params**

- NurbsCurveData object representing the curve
- u parameter
- v parameter

**returns**

- a Vector represented by an array of length (dim)

## rationalSurfaceNormal

**STATIC METHOD**

`rationalSurfaceNormal(surface : NurbsSurfaceData, u : Float, v : Float) : Array<Float>`

Compute the derivatives at a point on a NURBS surface

**params**

- NurbsSurfaceData object representing the surface
- u parameter
- v parameter

**returns**

- a Vector represented by an array of length (dim)

## rationalSurfaceDerivatives

**STATIC METHOD**

`rationalSurfaceDerivatives(surface : NurbsSurfaceData, u : Float, v : Float, numDerivs : Int) : Array<Array<Array<Float>>>`

Compute the derivatives at a point on a NURBS surface

**params**

- NurbsSurfaceData object representing the surface
- number of derivatives to evaluate
- u parameter at which to evaluate the derivatives
- v parameter at which to evaluate the derivatives

**returns**

- a point represented by an array of length (dim)

## rationalSurfacePoint

**STATIC METHOD**

`rationalSurfacePoint(surface : NurbsSurfaceData, u : Float, v : Float) : Point`

Compute a point on a NURBS surface

**params**

- integer degree of surface in u direction
- array of nondecreasing knot values in u direction
- integer degree of surface in v direction
- array of nondecreasing knot values in v direction
- 3d array of control points (tensor), top to bottom is increasing u direction, left to right is increasing v direction, and where each control point is an array of length (dim+1)
- u parameter at which to evaluate the surface point
- v parameter at which to evaluate the surface point

**returns**

- a point represented by an array of length (dim)

## rationalCurveDerivatives

**STATIC METHOD**

`rationalCurveDerivatives(curve : NurbsCurveData, u : Float, numDerivs : Int) : Array<Point>`

Determine the derivatives of a NURBS curve at a given parameter

**params**

- NurbsCurveData object representing the curve - the control points are in homogeneous coordinates
- parameter on the curve at which the point is to be evaluated
- number of derivatives to evaluate

**returns**

- a point represented by an array of length (dim)

## rationalCurvePoint

**STATIC METHOD**

`rationalCurvePoint(curve : NurbsCurveData, u : Float) : Point`

Compute a point on a NURBS curve

**params**

- integer degree of curve
- array of nondecreasing knot values
- 2d array of homogeneous control points, where each control point is an array of length (dim+1) and form (wi*pi, wi)
- parameter on the curve at which the point is to be evaluated

**returns**

- a point represented by an array of length (dim)

## surfaceDerivatives

**STATIC METHOD**

`surfaceDerivatives(surface : NurbsSurfaceData, u : Float, v : Float, numDerivs : Int) : Array<Array<Point>>`

Compute the derivatives on a non-uniform, non-rational B spline surface

**params**

- NurbsSurfaceData object representing the surface
- number of derivatives to evaluate
- u parameter at which to evaluate the derivatives
- v parameter at which to evaluate the derivatives

**returns**

- a 2d jagged array representing the derivatives - u derivatives increase by row, v by column

## surfaceDerivativesGivenNM

**STATIC METHOD**

`surfaceDerivativesGivenNM(n : Int, m : Int, surface : NurbsSurfaceData, u : Float, v : Float, numDerivs : Int) : Array<Array<Point>>`

Compute the derivatives on a non-uniform, non-rational B spline surface (corresponds to algorithm 3.6 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

- integer number of basis functions in u dir - 1 = knotsU.length - degreeU - 2
- integer number of basis functions in v dir - 1 = knotsU.length - degreeU - 2
- NurbsSurfaceData object representing the surface
- u parameter at which to evaluate the derivatives
- v parameter at which to evaluate the derivatives

**returns**

- a 2d jagged array representing the derivatives - u derivatives increase by row, v by column

## surfacePoint

**STATIC METHOD**

`surfacePoint(surface : NurbsSurfaceData, u : Float, v : Float) : Point`

Compute a point on a non-uniform, non-rational B-spline surface

**params**

- NurbsSurfaceData object representing the surface
- u parameter at which to evaluate the surface point
- v parameter at which to evaluate the surface point

**returns**

- a point represented by an array of length (dim)

## surfacePointGivenNM

**STATIC METHOD**

`surfacePointGivenNM(n : Int, m : Int, surface : NurbsSurfaceData, u : Float, v : Float) : Point`

Compute a point on a non-uniform, non-rational B spline surface (corresponds to algorithm 3.5 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

- integer number of basis functions in u dir - 1 = knotsU.length - degreeU - 2
- integer number of basis functions in v dir - 1 = knotsV.length - degreeV - 2
- NurbsSurfaceData object representing the surface
- u parameter at which to evaluate the surface point
- v parameter at which to evaluate the surface point

**returns**

- a point represented by an array of length (dim)

## curveDerivatives

**STATIC METHOD**

`curveDerivatives(crv : NurbsCurveData, u : Float, numDerivs : Int) : Array<Point>`

Determine the derivatives of a non-uniform, non-rational B-spline curve at a given parameter

**params**

- NurbsCurveData object representing the curve
- parameter on the curve at which the point is to be evaluated
- number of derivatives to evaluate

**returns**

- a point represented by an array of length (dim)

## curveDerivativesGivenN

**STATIC METHOD**

`curveDerivativesGivenN(n : Int, curve : NurbsCurveData, u : Float, numDerivs : Int) : Array<Point>`

Determine the derivatives of a non-uniform, non-rational B-spline curve at a given parameter (corresponds to algorithm 3.1 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

- integer number of basis functions - 1 = knots.length - degree - 2
- NurbsCurveData object representing the curve
- parameter on the curve at which the point is to be evaluated

**returns**

- a point represented by an array of length (dim)

## curvePoint

**STATIC METHOD**

`curvePoint(curve : NurbsCurveData, u : Float)`

Compute a point on a non-uniform, non-rational b-spline curve

**params**

- NurbsCurveData object representing the curve
- parameter on the curve at which the point is to be evaluated

**returns**

- a point represented by an array of length (dim)

## areValidRelations

**STATIC METHOD**

`areValidRelations(degree : Int, num_controlPoints : Int, knots_length : Int) : Bool`

Confirm the relations between degree (p), number of control points(n+1), and the number of knots (m+1) via The NURBS Book (section 3.2, Second Edition)

**params**

- integer degree
- integer number of control points
- integer length of the knot Array (including duplicate knots)

**returns**

- whether the values are correct

## curvePointGivenN

**STATIC METHOD**

`curvePointGivenN(n : Int, curve : NurbsCurveData, u : Float) : Point`

Compute a point on a non-uniform, non-rational b-spline curve (corresponds to algorithm 3.1 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

- integer number of basis functions - 1 = knots.length - degree - 2
- NurbsCurveData object representing the curve
- parameter on the curve at which the point is to be evaluated

**returns**

- a point represented by an array of length (dim)

## volumePoint

**STATIC METHOD**

`volumePoint(volume : VolumeData, u : Float, v : Float, w : Float) : Point`

Compute a point in a non-uniform, non-rational B spline volume

**params**

- VolumeData
- u parameter at which to evaluate the volume point
- v parameter at which to evaluate the volume point
- w parameter at which to evaluate the volume point

**returns**

- a point represented by an array of length (dim)

## volumePointGivenNML

**STATIC METHOD**

`volumePointGivenNML(volume : VolumeData, n : Int, m : Int, l : Int, u : Float, v : Float, w : Float) : Point`

Compute a point in a non-uniform, non-rational B spline volume

**params**

- VolumeData
- u parameter at which to evaluate the volume point
- v parameter at which to evaluate the volume point
- w parameter at which to evaluate the volume point

**returns**

- a point represented by an array of length (dim)

## derivativeBasisFunctions

**STATIC METHOD**

`derivativeBasisFunctions(u : Float, degree : Int, knots : KnotArray) : Array<Array<Float>>`

Compute the non-vanishing basis functions and their derivatives

**params**

- float parameter
- integer degree
- array of nondecreasing knot values

**returns**

- 2d array of basis and derivative values of size (n+1, p+1) The nth row is the nth derivative and the first row is made up of the basis function values.

## derivativeBasisFunctionsGivenNI

**STATIC METHOD**

`derivativeBasisFunctionsGivenNI(knotSpan_index : Int, u : Float, p : Int, n : Int, knots : KnotArray) : Array<Array<Float>>`

Compute the non-vanishing basis functions and their derivatives (corresponds to algorithm 2.3 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

- integer knot span index
- float parameter
- integer degree
- integer number of basis functions - 1 = knots.length - degree - 2
- array of nondecreasing knot values

**returns**

- 2d array of basis and derivative values of size (n+1, p+1) The nth row is the nth derivative and the first row is made up of the basis function values.

## basisFunctions

**STATIC METHOD**

`basisFunctions(u : Float, degree : Int, knots : KnotArray)`

Compute the non-vanishing basis functions

**params**

- float parameter
- integer degree of function
- array of nondecreasing knot values

**returns**

- list of non-vanishing basis functions

## basisFunctionsGivenKnotSpanIndex

**STATIC METHOD**

`basisFunctionsGivenKnotSpanIndex(knotSpan_index : Int, u : Float, degree : Int, knots : KnotArray)`

Compute the non-vanishing basis functions (corresponds to algorithm 2.2 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

*Number*, integer knot span index*Number*, float parameter*Number*, integer degree of function- array of nondecreasing knot values

**returns**

- list of non-vanishing basis functions

## knotSpan

**STATIC METHOD**

`knotSpan(degree : Int, u : Float, knots : Array<Float>) : Int`

Find the span on the knot Array without supplying n

**params**

- integer degree of function
- float parameter
- array of nondecreasing knot values

**returns**

- the index of the knot span

## knotSpanGivenN

**STATIC METHOD**

`knotSpanGivenN(n : Int, degree : Int, u : Float, knots : Array<Float>) : Int`

Find the span on the knot Array knots of the given parameter (corresponds to algorithm 2.1 from The NURBS book, Piegl & Tiller 2nd edition)

**params**

- integer number of basis functions - 1 = knots.length - degree - 2
- integer degree of function
- parameter
- array of nondecreasing knot values

**returns**

- the index of the knot span

## dehomogenize

**STATIC METHOD**

`dehomogenize(homoPoint : Point) : Point`

Dehomogenize a point

**params**

- a point represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- a point represented by an array pi with length (dim)

## rational1d

**STATIC METHOD**

`rational1d(homoPoints : Array<Point>) : Array<Point>`

Obtain the point from a point in homogeneous space without dehomogenization, assuming all are the same length

**params**

- array of points represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- array of points represented by an array (wi*pi) with length (dim)

## rational2d

**STATIC METHOD**

`rational2d(homoPoints : Array<Array<Point>>) : Array<Array<Point>>`

Obtain the weight from a collection of points in homogeneous space, assuming all are the same dimension

**params**

- array of arrays of of points represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- array of arrays of points, each represented by an array pi with length (dim)

## weight1d

**STATIC METHOD**

`weight1d(homoPoints : Array<Point>) : Array<Float>`

Obtain the weight from a collection of points in homogeneous space, assuming all are the same dimension

**params**

- array of points represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- a point represented by an array pi with length (dim)

## weight2d

**STATIC METHOD**

`weight2d(homoPoints : Array<Array<Point>>) : Array<Array<Float>>`

Obtain the weight from a collection of points in homogeneous space, assuming all are the same dimension

**params**

- array of arrays of of points represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- array of arrays of points, each represented by an array pi with length (dim)

## dehomogenize1d

**STATIC METHOD**

`dehomogenize1d(homoPoints : Array<Point>) : Array<Point>`

Dehomogenize an array of points

**params**

- array of points represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- an array of points, each of length dim

## dehomogenize2d

**STATIC METHOD**

`dehomogenize2d(homoPoints : Array<Array<Point>>) : Array<Array<Point>>`

Dehomogenize a 2d array of pts

**params**

- array of arrays of points represented by an array (wi*pi, wi) with length (dim+1)

**returns**

- array of arrays of points, each of length dim

## homogenize1d

**STATIC METHOD**

`homogenize1d(controlPoints : Array<Point>, weights : Array<Float>) : Array<Point>`

Transform a 1d array of points into their homogeneous equivalents

**params**

- 1d array of control points, (actually a 2d array of size (m x dim) )
- array of control point weights, the same size as the array of control points (m x 1)

**returns**

- 1d array of control points where each point is (wi*pi, wi) where wi i the ith control point weight and pi is the ith control point, hence the dimension of the point is dim + 1

## homogenize2d

**STATIC METHOD**

`homogenize2d(controlPoints : Array<Array<Point>>, weights : Array<Array<Float>>) : Array<Array<Point>>`

**params**

- 2d array of control points, (actually a 3d array of size m x n x dim)
- array of control point weights, the same size as the control points array (m x n x 1)

**returns**

- 1d array of control points where each point is (wi*pi, wi) where wi i the ith control point weight and pi is the ith control point, the size is (m x n x dim+1)