Evaluators

Evaluators (or geometric evaluation strategies) allow users to change shape evaluation strategy, i.e. the algorithms that are used to evaluate curves, surfaces and volumes, take derivatives and more. Therefore, the user can switch between the evaluation algorithms at runtime, implement and use different algorithms or extend existing ones.

How to Use

All geometry classes come with a default specialized evaluator class, the algorithms are generally different for rational and non-rational geometries. The evaluator class instance can be accessed and/or updated using evaluator property. For instance, the following code snippet changes the evaluator of a B-Spline curve.

from geomdl import BSpline
from geomdl import evaluators

crv = BSpline.Curve()
cevaltr = evaluators.CurveEvaluator2()
crv.evaluator = cevaltr

# Curve "evaluate" method will use CurveEvaluator2.evaluate() method
crv.evaluate()

# Get evaluated points
curve_points = crv.evalpts

Inheritance Diagram

Inheritance diagram of geomdl.evaluators

Abstract Base

class geomdl.evaluators.AbstractEvaluator(**kwargs)

Bases: object

Abstract base class for implementations of fundamental spline algorithms, such as evaluate and derivative.

Abstract Methods:

  • evaluate is used for computation of the complete spline shape
  • derivative_single is used for computation of derivatives at a single parametric coordinate

Please note that this class requires the keyword argument find_span_func to be set to a valid find_span function implementation. Please see helpers module for details.

derivatives(**kwargs)

Abstract method for computation of derivatives at a single parameter.

Note

This is an abstract method and it must be implemented in the subclass.

evaluate(**kwargs)

Abstract method for computation of points over a range of parameters.

Note

This is an abstract method and it must be implemented in the subclass.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str

Curve Evaluators

class geomdl.evaluators.CurveEvaluator(**kwargs)

Bases: geomdl.evaluators.AbstractEvaluator

Sequential curve evaluation algorithms.

This evaluator implements the following algorithms from The NURBS Book:

  • Algorithm A3.1: CurvePoint
  • Algorithm A3.2: CurveDerivsAlg1

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

evaluate(**kwargs)

Evaluates the curve.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str
class geomdl.evaluators.CurveEvaluator2(**kwargs)

Bases: geomdl.evaluators.CurveEvaluator

Sequential curve evaluation algorithms (alternative).

This evaluator implements the following algorithms from The NURBS Book:

  • Algorithm A3.1: CurvePoint
  • Algorithm A3.4: CurveDerivsAlg2

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

static derivatives_ctrlpts(**kwargs)

Computes the control points of all derivative curves up to and including the {degree}-th derivative.

Implementation of Algorithm A3.3 from The NURBS Book by Piegl & Tiller.

Output is PK[k][i], i-th control point of the k-th derivative curve where 0 <= k <= degree and r1 <= i <= r2-k.

evaluate(**kwargs)

Evaluates the curve.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str
class geomdl.evaluators.CurveEvaluatorRational(**kwargs)

Bases: geomdl.evaluators.CurveEvaluator

Sequential rational curve evaluation algorithms.

This evaluator implements the following algorithms from The NURBS Book:

  • Algorithm A3.1: CurvePoint
  • Algorithm A4.2: RatCurveDerivs

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

evaluate(**kwargs)

Evaluates the rational curve.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str

Surface Evaluators

class geomdl.evaluators.SurfaceEvaluator(**kwargs)

Bases: geomdl.evaluators.AbstractEvaluator

Sequential surface evaluation algorithms.

This evaluator implements the following algorithms from The NURBS Book:

  • Algorithm A3.5: SurfacePoint
  • Algorithm A3.6: SurfaceDerivsAlg1

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

evaluate(**kwargs)

Evaluates the surface.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str
class geomdl.evaluators.SurfaceEvaluator2(**kwargs)

Bases: geomdl.evaluators.SurfaceEvaluator

Sequential surface evaluation algorithms.

This evaluator implements the following algorithms from The NURBS Book:

  • Algorithm A3.5: SurfacePoint
  • Algorithm A3.7: SurfaceDerivCpts
  • Algorithm A3.8: SurfaceDerivsAlg2

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

static derivatives_ctrlpts(**kwargs)

Computes the control points of all derivative surfaces up to and including the {degree}-th derivative.

Output is PKL[k][l][i][j], i,j-th control point of the surface differentiated k times w.r.t to u and l times w.r.t v.

evaluate(**kwargs)

Evaluates the surface.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str
class geomdl.evaluators.SurfaceEvaluatorRational(**kwargs)

Bases: geomdl.evaluators.SurfaceEvaluator

Sequential rational surface evaluation algorithms.

This evaluator implements the following algorithms from The NURBS Book:

  • Algorithm A4.3: SurfacePoint
  • Algorithm A4.4: RatSurfaceDerivs

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

evaluate(**kwargs)

Evaluates the rational surface.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str

Volume Evaluators

class geomdl.evaluators.VolumeEvaluator(**kwargs)

Bases: geomdl.evaluators.AbstractEvaluator

Sequential volume evaluation algorithms.

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivative at the given parametric coordinate.

evaluate(**kwargs)

Evaluates the volume.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str
class geomdl.evaluators.VolumeEvaluatorRational(**kwargs)

Bases: geomdl.evaluators.VolumeEvaluator

Sequential rational volume evaluation algorithms.

Please note that knot vector span finding function may be changed by setting find_span_func keyword argument during the initialization. By default, this function is set to helpers.find_span_linear(). Please see Helpers Module Documentation for more details.

derivatives(**kwargs)

Evaluates the derivatives at the input parameter.

evaluate(**kwargs)

Evaluates the rational volume.

name

Evaluator name.

Getter:Gets the name of the evaluator
Type:str