simple VEX not working
2197
3
0
Chen_3207
Member
5 posts
Joined: Sept. 2018
Offline
April 13, 2019 1:21 p.m.
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)
Aizatulin
Member
504 posts
Joined: July 2005
Offline
April 15, 2019 1:53 p.m.
Hi,
this problem is due to numerical accuracy. To avoid this you can replace the if condition by
if (xtest >= xbbox - 1e-4 )
jsmack
Member
8183 posts
Joined: Sept. 2011
Offline
April 15, 2019 1:53 p.m.
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 );
Chen_3207
Member
5 posts
Joined: Sept. 2018
Offline
April 16, 2019 10:43 p.m.
Aizatulin Hi, this problem is due to numerical accuracy. To avoid this you can replace the if condition byif (xtest >= xbbox - 1e-4 )
It's worked!Thank you!