Normalized distance from an anchor point using the specified metric.
- Parameters
-
| anchor | Reference point |
| radius | Normalizing distance (output is 1.0 at this distance) |
| metric | Distance 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: {
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}
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().