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

◆ compute_path_curvature()

MAYAFLUX_API std::vector< Kakshya::LineVertex > MayaFlux::Kinesis::compute_path_curvature ( const std::vector< Kakshya::LineVertex > &  path_vertices,
float  curvature_scale,
size_t  stride = 1 
)

Compute curvature vectors along a path (2nd derivative approximation)

Parameters
path_verticesSequential vertices defining curve
curvature_scaleMagnitude scaling factor
strideSample every stride-th vertex
Returns
Line segments representing discrete curvature

Curvature at i approximated by: (v[i+1] - 2*v[i] + v[i-1])

Definition at line 393 of file GeometryPrimitives.cpp.

397{
398 if (path_vertices.size() < 3 || stride == 0) {
399 return {};
400 }
401
402 std::vector<Kakshya::LineVertex> curvatures;
403 curvatures.reserve((path_vertices.size() - 2) / stride * 2);
404
405 for (size_t i = 1; i < path_vertices.size() - 1; i += stride) {
406 glm::vec3 p_prev = path_vertices[i - 1].position;
407 glm::vec3 p_curr = path_vertices[i].position;
408 glm::vec3 p_next = path_vertices[i + 1].position;
409
410 glm::vec3 curvature = (p_next - 2.0F * p_curr + p_prev) * curvature_scale;
411
412 glm::vec3 color = path_vertices[i].color;
413 float thickness = path_vertices[i].thickness;
414
415 curvatures.push_back({ .position = p_curr,
416 .color = color,
417 .thickness = thickness });
418
419 curvatures.push_back({ .position = p_curr + curvature,
420 .color = color,
421 .thickness = thickness });
422 }
423
424 return curvatures;
425}
glm::vec3 color
Definition Decoder.cpp:97
float curvature(const glm::vec2 &vel, const glm::vec2 &accel, float min_speed=1e-3F) noexcept
Signed curvature from velocity and acceleration.

References color, and curvature().

Referenced by MayaFlux::Nodes::GpuSync::LineSegmentsNode::add_curvature().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: