MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ central_difference_tangents()

MAYAFLUX_API void MayaFlux::Kinesis::central_difference_tangents ( std::span< const double >  points,
size_t  dim,
size_t  count,
std::vector< double > &  tangents 
)

Tangents of a sampled curve by finite difference, coordinate-major.

Parameters
pointsCoordinate-major, dim * count doubles.
dimCoordinate count per sample, at least 1.
countSample count, at least 2.
tangentsResized to dim * count, coordinate-major.

For curves whose samples did not come straight from CurveEvaluator's analytic derivative, most importantly after reparameterize_planar has resampled by arc length, which leaves analytic tangents attached to the original parameter values. Uniformly spaced samples make the central difference well conditioned; the endpoints take the one sided difference.

Like the analytic tangents, these are directions and not rates.

Definition at line 334 of file MotionCurves.cpp.

339{
340 if (dim == 0 || count < 2 || points.size() < dim * count) {
341 tangents.assign(dim * count, 0.0);
342 return;
343 }
344
345 tangents.resize(dim * count);
346
347 for (size_t d = 0; d < dim; ++d) {
348 const double* row = points.data() + d * count;
349 double* out = tangents.data() + d * count;
350
351 for (size_t i = 0; i < count; ++i) {
352 const size_t a = i == 0 ? 0 : i - 1;
353 const size_t b = i + 1 < count ? i + 1 : count - 1;
354 out[i] = row[b] - row[a];
355 }
356 }
357}
std::vector< glm::vec2 > * points
size_t a
size_t b
std::vector< float > * out
size_t count

References a, b, count, out, and points.

Referenced by MayaFlux::Nodes::GpuSync::TopologyGeneratorNode::build_interpolated_path(), and MayaFlux::Nodes::GpuSync::PathGeneratorNode::write_curve_segment().

+ Here is the caller graph for this function: