foible50 Posted October 31, 2015 Share Posted October 31, 2015 I recently saw an example of someone having used the distance expression to isolate a point on a separate geometry which shared the same position. They used it in the following expression: if(distance($TX, $TY, $TZ, point("../each1", 0, "P", 0), point("../each1", 0, "P", 1), point("../each1", 0, "P", 2)) == 0,1,0) When the delete node was put to 'delete non-selected' it seemed to have the desired effect of deleting all the points from the incoming geometry, except the one sharing the precise location as point 0 from the 'each1' node. What I can't make sense of is why the distance is 0, 1, 0 and not 0, 0, 0, as I would've thought that there should be no distance between them. I hope I've explained this clearly enough to make it make some sense - I've included a hip file beneath - but if anyone could give me an answer then I'd be really grateful as I've been puzzling over it for weeks! Many thanks Toby distanceExpressionMystery.hipnc Quote Link to comment Share on other sites More sharing options...
merlino Posted October 31, 2015 Share Posted October 31, 2015 I think it's just about the if statement: if(condition, do this if True, do this if False) so if(distance is equal to 0, set to 1, otherwise set to 0) actually condition = distance($TX, $TY, $TZ, point("../each1", 0, "P", 0), point("../each1", 0, "P", 1), point("../each1", 0, "P", 2)) == 0 if(distance($TX, $TY, $TZ, point("../each1", 0, "P", 0), point("../each1", 0, "P", 1), point("../each1", 0, "P", 2)) == 0,1,) I suppose isn't necessary the "if" statement, it should works putting the condition itself and the answer will be 1 for True and 0 for False, but I may be wrong Quote Link to comment Share on other sites More sharing options...
foible50 Posted November 3, 2015 Author Share Posted November 3, 2015 Thank you so much for answering this and so thoroughly - it seems obvious now you say it, I just got confused by the format and it was driving me crazy feeling like I couldn't work it out. Many, many thanks! Quote Link to comment Share on other sites More sharing options...
f1480187 Posted November 3, 2015 Share Posted November 3, 2015 You also can split long expressions to make it more readable. { float x = point("../each1", 0, "P", 0); float y = point("../each1", 0, "P", 1); float z = point("../each1", 0, "P", 2); return distance($TX, $TY, $TZ, x, y, z) == 0; } Some reference on HScript Expressions syntax. 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.