pub enum TValue {
Parametric(f64),
Euclidean(f64),
EuclideanWithinError {
t: f64,
error: f64,
},
}
Expand description
A structure which can be used to reference a particular point along a Bezier
.
Assuming a 2-dimensional Bezier is represented as a parametric curve defined by components (x(f(t), y(f(t))))
, this structure defines variants for f(t)
.
- The
Parametric
variant represents the point calculated using the parametric equation of the curve at argumentt
. That is,f(t) = t
. Speed along the curve’s parametric form is not constant.t
must lie in the range[0, 1]
. - The
Euclidean
variant represents the point calculated at a distance ratiot
along the arc length of the curve in the range[0, 1]
. Speed is constant along the curve’s arc length.- E.g. If
d
is the distance from the start point of aBezier
to a certain point along the curve, andl
is the total arc length of the curve, that certain point lies at a distance ratiot = d / l
. - All
Bezier
functions will implicitly convert a Euclidean TValue argument to a parametrict
-value using binary search, computed within a particular error. That is, a point at distance ratiot*
, satisfying|t* - t| <= error
. The default error is0.001
. Given this requires a lengthier calculation, it is not recommended to use theEuclidean
orEuclideanWithinError
variants frequently in computationally intensive tasks.
- E.g. If
- The
EuclideanWithinError
variant functions exactly as theEuclidean
variant, but allows theerror
to be customized when computingt
internally.