Which face is closest?
-
3 faces connected on 1 edge.
Want to know which face is closest to face1 (face2 or face3),if I look from the back face side.
I know face2 is closest,but want Ruby to decide
I have experimented with normal.angle_between but no success.
Any suggestions?
-
How about comparing distance to face center points (face.bounds.center)?
-
@kyyu said:
How about comparing distance to face center points (face.bounds.center)?
Hmm,seems too dependent of the face size.Should be size independent and also face shape independent.
-
'Closest' is an inappropriate term [to be picky it should be 'closer' as there are only two more to choose from].
If we only have two faces we just know the second face is always 'closest' to the first face.
When we have three [OR more faces] they all have normal vectors.
We take the normal of the initial face and compare it to the normals of the others.
We do this using v0.angle_between(v1), v0.angle_between(v2) etc.
There are several possible outcomes...
The angles are all the same - therefore no face is 'closest' OR they all are!
Some faces [assuming that there are more than two to choose from] share the same minimum subtended angle - so now we have some 'closest faces'.
There is only one face that subtends an angle which is less than any of the others, and therefore we now have the 'closest' face.
You cannot have arbitrary rules about the front/back of the face.
You can test for the initial face actual normal and normal.reverse - you will/might get two results... BUT how will you choose which one to use ?? -
@tig said:
You cannot have arbitrary rules about the front/back of the face.
This is the biggest sub-problem in this problem,I think.
There is a face side entity missing. -
Please explain what you mean exactly ?
I don't understand you...
If you want to know the orientation of a face relative to its edge, then use this http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#reversed_in?
You can then compare the three faces sharing a common edge and if one is 'backwards' usedface.reverse!
OR useface.normal.reverse
in the testing ??? -
@tig said:
If you want to know the orientation of a face relative to its edge, then use this http://code.google.com/apis/sketchup/docs/ourdoc/edge.html#reversed_in?
You can then compare the three faces sharing a common edge and if one is 'backwards' usedface.reverse!
OR useface.normal.reverse
in the testing ???This could be exactly what I need,have to test first.
Thanks.
Advertisement