mois23 Posted July 28, 2021 Share Posted July 28, 2021 (edited) Hi there, just a quick one. I have a cloud of points with an attribute that goes from -1 to 1. Now, if a value it's really small and close to zero (ie 0.00001 or 1e-09), how I can round it to zero? And how I can do it based on decimal? Ie, if value is 0.001 or -0.001 I want to keep it as it is; if value is 0.0001 or -0.0001 I want it to be 0. How I can do it in VEX? Thank you so much!! Edited July 28, 2021 by mois23 Quote Link to comment Share on other sites More sharing options...
konstantin magnus Posted July 28, 2021 Share Posted July 28, 2021 (edited) Hi Mattia, here are a few examples on snapping or shifting values: 1) Once you have set the value to absolute with abs(), you can compare it to a threshold like 1e-1. Between more than -1 and less than <1 truncating will result to 0. if(abs(v@P.y) < 1e-1) {v@P.y = trunc(v@P.y);} 2) With vectors calculating the distance() returns a value that can be compared: if(distance(v@P, pos) < 1e-1) {v@P = pos;} 3) For transitions (or a cheap wormhole effect) the smooth function remaps values to between 0.0 and 1.0 float dist = distance(v@P, pos); float mask = 1.0 - smooth(0.0, thresh, dist, rolloff); v@P = lerp(v@P, pos, mask); zero.hiplc Edited July 28, 2021 by konstantin magnus 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.