ianmackenzie/elm-geometry/3.10.1

NOTE: the latest version is 4.0.0

ArcLengthParameterization

You will likely never need to use this module directly. In the vast majority of cases the individual curve modules such as QuadraticSpline2d should contain all the functionality you need to construct an arc length parameterization and use it to do things like evaluate a curve at evenly-spaced points. This module is primarily for use internally by those curve modules, but may be useful if you want to do some fancy mapping between arc length and curve parameter values.

Contains a mapping from curve parameter value to arc length, and vice versa. Parameter values are assumed to range from 0 to 1.

Constructing

{ derivativeMagnitude : Float -> Quantity Float units
, maxSecondDerivativeMagnitude : Quantity Float units
, maxError : Quantity Float units
}

Build an arc length parameterization for some curve. You must supply:

  • A derivativeMagnitude function that returns the magnitude of the first derivative of the curve at a given parameter value
  • The maximum magnitude of the second derivative of the curve
  • A tolerance specifying the maximum error of the resulting parameterization

Evaluating

totalArcLength : ArcLengthParameterization units -> Quantity Float units

Find the total arc length of some curve given its arc length parameterization;

ArcLengthParameterization.totalArcLength
    parameterization

is equivalent to

ArcLengthParameterization.parameterValueToArcLength 1
    parameterization

but is more efficient. The arc length will be accurate to within the maximum error specified when building the parameterization.

arcLengthToParameterValue : Quantity Float units -> ArcLengthParameterization units -> Float

Convert an arc length to the corresponding parameter value. The given arc length will be clamped to the range [0, length].

parameterValueToArcLength : Float -> ArcLengthParameterization units -> Quantity Float units

Convert a parameter value to the corresponding arc length. The parameter value will be clamped to the range [0, 1].