oatcracker Posted September 28, 2014 Share Posted September 28, 2014 Hi, may I ask how to get the largest circle inside a concave polygon in whatever shape in Houdini? Thanks! Quote Link to comment Share on other sites More sharing options...
oatcracker Posted September 28, 2014 Author Share Posted September 28, 2014 sorry, what I mean is convex shape polygon ... Quote Link to comment Share on other sites More sharing options...
eetu Posted September 28, 2014 Share Posted September 28, 2014 An interesting problem, this It seems there is no general solution for this (after some googling). Here is a try using iteration - in some cases this method converges very slowly (you can spot the nonoptimal ones in the screenshot) so there is clear room for improvement. Also you could check for triangles and use the exact solution for those. ee_incircles.hip 1 Quote Link to comment Share on other sites More sharing options...
Shinjipierre Posted September 28, 2014 Share Posted September 28, 2014 (edited) Thought that was a fun problem as well. (how nerdy is that on a scale of 1 to Stephen Hawking?)I did my own quick answer to it. It could be optimized with iterations instead of sampling zillion of times but I'm lazy I also added a counter to check which answer has most area covered. edit : noticed that I forgot to attach my file.... ee_incircles_v2.hipnc Edited September 29, 2014 by Shinjipierre Quote Link to comment Share on other sites More sharing options...
oat Posted September 29, 2014 Share Posted September 29, 2014 interesting solution, eetu! May I ask what's going on inside the foreach_iterate node, especially the two ray nodes? Thanks! Quote Link to comment Share on other sites More sharing options...
eetu Posted September 29, 2014 Share Posted September 29, 2014 The ray node finds the closest point on the polygon edges, and then the following point node nudges the center point away from that direction. Repeat many times, always nudging by a smaller amount, and you should end up with a pretty good approximation of the point where there is the most room around it. Shinjipierre's brute force method uses point cloud lookups to find the closest point, which is probably quite a bit faster. His method seems to be quite a bit faster with better results, so I recommend using that (And it works with inconvex shapes as well) Quote Link to comment Share on other sites More sharing options...
Skybar Posted September 29, 2014 Share Posted September 29, 2014 A bit slow, but a quickie 3D-version with: ee_incircles_v3.hipnc Quote Link to comment Share on other sites More sharing options...
3__ Posted September 30, 2014 Share Posted September 30, 2014 clever answers next question: how would you get the largest rectangle inside the polygon? Quote Link to comment Share on other sites More sharing options...
magneto Posted September 30, 2014 Share Posted September 30, 2014 Is there a non-approximate way to do this? Quote Link to comment Share on other sites More sharing options...
eetu Posted September 30, 2014 Share Posted September 30, 2014 (edited) Is there a non-approximate way to do this? As far as I know, nope. (except for triangles) clever answers next question: how would you get the largest rectangle inside the polygon? Now that is nasty Edited September 30, 2014 by eetu 1 Quote Link to comment Share on other sites More sharing options...
magneto Posted September 30, 2014 Share Posted September 30, 2014 As far as I know, nope. (except for triangles) Do you think one could do this for triangles defined by the polygon and then combine these circles? I assume calculating the circle that contains other circles is trivial? Quote Link to comment Share on other sites More sharing options...
eetu Posted September 30, 2014 Share Posted September 30, 2014 Do you think one could do this for triangles defined by the polygon and then combine these circles? I assume calculating the circle that contains other circles is trivial? Sadly, I don't think it works that way, but keep thinking! 1 Quote Link to comment Share on other sites More sharing options...
Shinjipierre Posted September 30, 2014 Share Posted September 30, 2014 how would you get the largest rectangle inside the polygon? You mean, largest area, I guess... That sounds complicated Quote Link to comment Share on other sites More sharing options...
petz Posted September 30, 2014 Share Posted September 30, 2014 Is there a non-approximate way to do this? one way would be to solve it geometrically by building the polygon skeleton. one of the resulting points is per definition the centerpoint of the largest inscribed circle. should also work with non-convex polygons. the following example might be a good start http://forums.odforce.net/topic/14151-roof-generator/?p=116552 2 Quote Link to comment Share on other sites More sharing options...
eetu Posted September 30, 2014 Share Posted September 30, 2014 one way would be to solve it geometrically by building the polygon skeleton. one of the resulting points is per definition the centerpoint of the largest inscribed circle. should also work with non-convex polygons. the following example might be a good start Ohhhh that's very interesting, I didn't realize that at all. cool! Quote Link to comment Share on other sites More sharing options...
magneto Posted October 1, 2014 Share Posted October 1, 2014 one way would be to solve it geometrically by building the polygon skeleton. one of the resulting points is per definition the centerpoint of the largest inscribed circle. should also work with non-convex polygons.the following example might be a good start http://forums.odforce.net/topic/14151-roof-generator/?p=116552 Thansk petz, I was expecting you Quote Link to comment Share on other sites More sharing options...
oat Posted October 5, 2014 Share Posted October 5, 2014 Thank you all very much! I got a lot to digest and learn from your advices, especailly the iterative process. Much obligied! Quote Link to comment Share on other sites More sharing options...
Shinjipierre Posted October 5, 2014 Share Posted October 5, 2014 one way would be to solve it geometrically by building the polygon skeleton. one of the resulting points is per definition the centerpoint of the largest inscribed circle. should also work with non-convex polygons. But that center point also seems to be approximated. (briefly looking at the file, that's a cool process). Also, with that method you'll still have to approximate the largest radius by sampling the edges, nah? Quote Link to comment Share on other sites More sharing options...
petz Posted October 5, 2014 Share Posted October 5, 2014 But that center point also seems to be approximated. (briefly looking at the file, that's a cool process). Also, with that method you'll still have to approximate the largest radius by sampling the edges, nah? why would that be an approximation? the polygon skeleton can be computed with floating point precision and if you have the skeleton you also have the exact centerpoint of the largest circle. the only thing left to do is finding the radius. this could be done with a bit of vector math (again floating point precision) or for example by using xyzdist() in vex. so, all in all i would say you´ll get a pretty good result. sampling the edges is not necessary since you just need the distance between a point and a line. well, not entirely true as long as you are using xyzdist() because this function relays on GU_RayIntersect where the distance is computed essentially by shooting rays. but i´m not sure if this is what you meant? largest_circle.hipnc 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.