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

◆ distance()

SpatialField MayaFlux::Kinesis::distance ( const glm::vec3 &  anchor,
float  radius,
DistanceMetric  metric = DistanceMetric::EUCLIDEAN 
)
inline

Normalized distance from an anchor point using the specified metric.

Parameters
anchorReference point
radiusNormalizing distance (output is 1.0 at this distance)
metricDistance computation strategy
Returns
SpatialField: glm::vec3 -> float

Returns raw normalized distance. Compose with transfer_curve, smoothstep, sigmoid, or any ScalarField via chain() to shape the result.

Definition at line 49 of file TendencyFactories.hpp.

53{
54 switch (metric) {
55 case DistanceMetric::EUCLIDEAN:
56 return { .fn = [anchor, radius](const glm::vec3& p) -> float {
57 return glm::length(p - anchor) / radius;
58 } };
59 case DistanceMetric::EUCLIDEAN_SQUARED: {
60 float r_sq = radius * radius;
61 return { .fn = [anchor, r_sq](const glm::vec3& p) -> float {
62 glm::vec3 d = p - anchor;
63 return glm::dot(d, d) / r_sq;
64 } };
65 }
66 case DistanceMetric::MANHATTAN:
67 return { .fn = [anchor, radius](const glm::vec3& p) -> float {
68 glm::vec3 d = glm::abs(p - anchor);
69 return (d.x + d.y + d.z) / radius;
70 } };
71 case DistanceMetric::CHEBYSHEV:
72 return { .fn = [anchor, radius](const glm::vec3& p) -> float {
73 glm::vec3 d = glm::abs(p - anchor);
74 return std::max({ d.x, d.y, d.z }) / radius;
75 } };
76 }
77 return { .fn = [anchor, radius](const glm::vec3& p) -> float {
78 return glm::length(p - anchor) / radius;
79 } };
80}
Range radius

References CHEBYSHEV, EUCLIDEAN, EUCLIDEAN_SQUARED, MayaFlux::Kinesis::Tendency< D, R >::fn, MANHATTAN, and radius.

Referenced by minimum_spanning_tree(), project_onto_plane(), ray_cast(), and relative_neighborhood_graph().

+ Here is the caller graph for this function: