simple VEX not working

   2197   3   0
User Avatar
Member
5 posts
Joined: Sept. 2018
Offline
Hello everyone,

English is not my native language,sorry for that.

I'm trying to use VEX to create a points group of a grid's both side and it worked,just like the first screenshot.But when I change the grid's size,sometimes only one side is selected like second screenshot.Maybe there are other ways to do this trick,I just wonder where am I wrong.

Thanks.

Attachments:
1.PNG (67.6 KB)
2.PNG (63.6 KB)
3.PNG (28.9 KB)
grid_vex.hipnc (98.4 KB)

User Avatar
Member
504 posts
Joined: July 2005
Offline
Hi,

this problem is due to numerical accuracy. To avoid this you can replace the if condition by
if (xtest >= xbbox - 1e-4)
User Avatar
Member
8183 posts
Joined: Sept. 2011
Offline
Due to floating point precision limits it's better to test min and max, rather than assuming an exact match with the absolute value.

float min = getbbox_min(0).x;
float max = getbbox_max(0).x;
float xtest = @P.x;

i@side = (xtest == min) || (xtest == max);
User Avatar
Member
5 posts
Joined: Sept. 2018
Offline
Aizatulin
Hi,

this problem is due to numerical accuracy. To avoid this you can replace the if condition by
if (xtest >= xbbox - 1e-4)
It's worked!Thank you!
  • Quick Links