Skip to content

Instantly share code, notes, and snippets.

@simonreeves
Last active February 6, 2024 22:37

Revisions

  1. simonreeves revised this gist Aug 8, 2019. 1 changed file with 4 additions and 1 deletion.
    5 changes: 4 additions & 1 deletion houdini_vex_wrangle_get_distance_to_points.c
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,12 @@ vector np_pos = point(1, 'P', np);
    // measure distance
    float dist = distance(@P, np_pos);

    // rescale distance
    // normalise distance
    dist = fit(dist, ch('in_min'), ch('in_max'), ch('out_min'), ch('out_max'));

    // remap with ramp
    dist = chramp('remap', dist);

    // set attribute
    f@dist = dist;

  2. simonreeves created this gist Aug 8, 2019.
    15 changes: 15 additions & 0 deletions houdini_vex_wrangle_get_distance_to_points.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // get nearest point index of second input
    int np = nearpoint(1, @P);

    // get that point's position
    vector np_pos = point(1, 'P', np);

    // measure distance
    float dist = distance(@P, np_pos);

    // rescale distance
    dist = fit(dist, ch('in_min'), ch('in_max'), ch('out_min'), ch('out_max'));

    // set attribute
    f@dist = dist;