How to detect if two faces are EXACTLY coplanar or not?
-
So, I've made a script that erases any lines in-between coplanar faces. The only way that I could think of detecting if they are coplanar is by checking their normals for equality, but the returned normal is an approximation, not the true value . And thus my script erases lines in-between faces that are close - but not absolutely - co-planar and destroys the faces in the process. Any ideas on how to detect if they are ABSOLUTELY co-planar?
I've got one... hehe -
yeah see that's one thing I know nothing about ruby... and I mean nothing.
hopefully someone will save us from stumpage. -
Well, define your use of "coplanar". Coplanar means "on the same plane". So:
if face1.plane == face2.plane then puts "faces are coplanar" ; end ;
Now, if you also mean 100% "coincident", then the defined bounding box of each face will match.
If you mean partially overlapping, then tests would have to be made with various points (vertices) on one face with the bounding box of the other face, and then vice versa as well.
Todd
-
Well, are plane values exact? That I will check tomorrow. As for stumpage you might still be in it.
-
-
@unknownuser said:
I've got one... hehe
What's that about? What do you have? Can everyone have one? :smile:
I had to pull out my superhero eyeglasses to read that!
-
This may not be the best solution, but the logic is sound..
Check for deleted faces just after erasing the edge, and if the face is also deleted, undo and continue with the next edge in the loop.
It may not be too costly because the trash loop is already a limited set containing only edges that are candidates for removal. But then again, I've noticed skin.rb can get slow already (not your fault.)
-
Ok, I must admit that not knowing how to fix this was pretty stupid. It was the second method I wrote on my first script and I wasn't - and I still am not - very knowledgeable about the API. The only reason that I thought it would stump you guys is that the STUPID google employee at the sketchup help group (not pro) told me that an approximation was as close as I could get ! Now I know that he is wrong, because planes do give acurite data! And as for the idea that I had I was thinking that if creating a face with the two faces edges (minus the in-between edge) was successful than I could erase the line. And Jim, you said that skin.rb runs slowly, well it does because of how many nested iterations through arrays I had (every face was processed once for every edge it had, every edge was processed twice, and every vertex was processed at least twice for every line attached to it!), it should run faster with the next version.
-
Yeehaaa
here's a dummy way with a tetrahedron
fudge your model with a face on x,y plane and one edge on the x axis - you hope. this face must be filled
draw a flat rectangle joining this edge at both end and extend along the flat plane y. It should fill by itself. the line in between can be removed and it should all fill - if not you screwed up placing your model
I think this is fundamental to any modelling (would you start a 2d drg without an origin, scale and xy directions
Advertisement