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

◆ compute_path_tangents()

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

Compute tangent vectors along a piecewise-linear path.

Parameters
path_verticesSequential vertices defining curve
tangent_lengthMagnitude of tangent vectors
strideSample every stride-th vertex
Returns
Line segments (pairs) representing tangents (for LINE_LIST topology)

Tangent at vertex i: direction (v[i+1] - v[i]) Returned as pairs: [vertex - tangent/2, vertex + tangent/2]

Definition at line 353 of file GeometryPrimitives.cpp.

357{
358 if (path_vertices.size() < 2 || stride == 0) {
359 return {};
360 }
361
362 std::vector<Kakshya::LineVertex> tangents;
363 tangents.reserve((path_vertices.size() - 1) / stride * 2);
364
365 for (size_t i = 0; i < path_vertices.size() - 1; i += stride) {
366 glm::vec3 p0 = path_vertices[i].position;
367 glm::vec3 p1 = path_vertices[i + 1].position;
368
369 glm::vec3 tangent = p1 - p0;
370 float length = glm::length(tangent);
371
372 if (length < 1e-6F) {
373 continue;
374 }
375
376 tangent = glm::normalize(tangent) * tangent_length;
377
378 glm::vec3 color = path_vertices[i].color;
379 float thickness = path_vertices[i].thickness;
380
381 tangents.push_back({ .position = p0 - tangent * 0.5F,
382 .color = color,
383 .thickness = thickness });
384
385 tangents.push_back({ .position = p0 + tangent * 0.5F,
386 .color = color,
387 .thickness = thickness });
388 }
389
390 return tangents;
391}
uint64_t length
Definition Composite.cpp:11
glm::vec3 color
Definition Decoder.cpp:97
uint32_t tangent

References color, length, and tangent.

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

+ Here is the caller graph for this function: