oat Posted March 16, 2011 Share Posted March 16, 2011 suppose i know the coordinates of two points, how can i find out if there're any geometries intersecting with the line formed by these two points? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
lukeiamyourfather Posted March 16, 2011 Share Posted March 16, 2011 (edited) Since this is Houdini we're talking about, there's probably a million ways to do it all of which are correct. I'd use an Add SOP to make a line between the two points, use the Resample SOP to make a bunch of points between the two, use an Attribute Transfer SOP and Attribute Create SOP to transfer whatever attribute you want onto potential objects in between, then lastly use Attribute Promote SOP (and maybe a For Each SOP) to push the point attribute to groups or whatever is needed. Also useful might be the Ray SOP which is a completely different way of solving the problem. Edited March 16, 2011 by lukeiamyourfather Quote Link to comment Share on other sites More sharing options...
graham Posted March 16, 2011 Share Posted March 16, 2011 My first thought would be to test using some sort of ray. In the attached file there are two examples of using the Ray SOP or a VOP SOP using Intersect. A vector is computed from pt0 to pt1 and is used as the ray direction. In the case of the Ray SOP, if the dist point attr is > 0 then there is something in the way. In the case of the VOP setup if the hit attr is not -1 then there has been a collision. ray_test_intersections.hip Quote Link to comment Share on other sites More sharing options...
oat Posted March 16, 2011 Author Share Posted March 16, 2011 (edited) Hi, lukeiamyourfather, Thanks for your reply! Can you kindly help to use a demo file to explain how the process you suggest works? Thanks! Edited March 16, 2011 by oat Quote Link to comment Share on other sites More sharing options...
oat Posted March 16, 2011 Author Share Posted March 16, 2011 My first thought would be to test using some sort of ray. In the attached file there are two examples of using the Ray SOP or a VOP SOP using Intersect. A vector is computed from pt0 to pt1 and is used as the ray direction. In the case of the Ray SOP, if the dist point attr is > 0 then there is something in the way. In the case of the VOP setup if the hit attr is not -1 then there has been a collision. dear graham, thanks a lot! will take some time to digest the approach you suggested. Quote Link to comment Share on other sites More sharing options...
oat Posted March 17, 2011 Author Share Posted March 17, 2011 (edited) My first thought would be to test using some sort of ray. In the attached file there are two examples of using the Ray SOP or a VOP SOP using Intersect. A vector is computed from pt0 to pt1 and is used as the ray direction. In the case of the Ray SOP, if the dist point attr is > 0 then there is something in the way. In the case of the VOP setup if the hit attr is not -1 then there has been a collision. dear graham, thank you very much! It seems the "ray" method works fine, but the pure VOP SOP method doesn't work in certain situation as shown in the attached hip file. In the hip file one of the point is inside a box but the dist value obtained is zero. can you kindly help to take a look and suggest a solution? BTW, tamte posted almost the same method as yours in the Houdini apprentice forum for the same question I post here: http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&p=101656#101656 Thank you in advance! Edited March 17, 2011 by oat Quote Link to comment Share on other sites More sharing options...
graham Posted March 17, 2011 Share Posted March 17, 2011 Can you attach the hip file? Quote Link to comment Share on other sites More sharing options...
oat Posted March 17, 2011 Author Share Posted March 17, 2011 Can you attach the hip file? Sorry sorry sorry! here's the hip file thank you very much for your kind help!!! ray_test_intersections1.hipnc Quote Link to comment Share on other sites More sharing options...
graham Posted March 17, 2011 Share Posted March 17, 2011 Sorry, that is my bad. The VOP SOP method works fine, however the Ray SOP doesn't. I accidentally left an incorrect value for the Max Ray Dist. It should be length($NX, $NY, $NZ) instead of just $NX. Attached is the VOP method wrapped in an asset. It provides a more straight forward boolean as to whether or not an intersection exists, as well as a bit more information about any intersection that might be occurring. sop_lineintersection.otl 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.