MayaFlux 0.4.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 293 of file GeometryPrimitives.cpp.

297{
298 if (path_vertices.size() < 2 || stride == 0) {
299 return {};
300 }
301
302 std::vector<Kakshya::LineVertex> tangents;
303 tangents.reserve((path_vertices.size() - 1) / stride * 2);
304
305 for (size_t i = 0; i < path_vertices.size() - 1; i += stride) {
306 glm::vec3 p0 = path_vertices[i].position;
307 glm::vec3 p1 = path_vertices[i + 1].position;
308
309 glm::vec3 tangent = p1 - p0;
310 float length = glm::length(tangent);
311
312 if (length < 1e-6F) {
313 continue;
314 }
315
316 tangent = glm::normalize(tangent) * tangent_length;
317
318 glm::vec3 color = path_vertices[i].color;
319 float thickness = path_vertices[i].thickness;
320
321 tangents.push_back({ .position = p0 - tangent * 0.5F,
322 .color = color,
323 .thickness = thickness });
324
325 tangents.push_back({ .position = p0 + tangent * 0.5F,
326 .color = color,
327 .thickness = thickness });
328 }
329
330 return tangents;
331}

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

+ Here is the caller graph for this function: