algorithmic modeling for Rhino
The A output of the VectorAngle will always be the one smaller then 180 degrees. You need to determine whether the normals are parallel or antiparallel. If they are antiparallel, use the reflex angle R.
Antiparallel vectors will have a negative dot product. Parallel vectors will have a positive dot product.
Thanks Hannes, very useful information. Now I solve the problem.
Hi!
Just a try but it works with your examples. Maybe you can improve it.
Greetings!
Hi TJO,
thanks for the example. Is pretty complex for me.I need to study it carefully.
Thank you!
Hi Leo!
I simplified my solution and will try to explain how it works:
We have two normal vectors u and v and the problem is, that the faces of this two vectors can be concave (A) or convex (B). We need a criterion to check which case we have.
Checking u and v for parallelity will not help us at this moment because in both cases their scalar product is positive. Also the cross product will not get us anywhere because we do not know the order of the vectors.
We need additional information!
We use the midpoints of the two faces to construct a third vector w. It will work also with other points as long as w connects the two faces, is not zero,… Using the midpoints seems to be a good idea because we have already calculated them.
We see that for concave faces the angle between u and w is smaller than 180°. For convex faces the angle is larger than 180°. So we can calculate the scalar product of u and w and check its sign like Hannes mentioned in his post. According to the sign we use the smaller or the larger angle between u and v.
Finally we use this formula
(Deg(x) + 180) mod 360
to convert the angle to degrees [Deg(x)], calculate the face angle [... -180] and make angles positive [(... +360) mod 360].
You're right. The scalar product flips ther sign at +-90 degrees, which is useless in this case. The center to center vector is a nice trick.
Expression evaluation tends to take lots of time to solve. Since we already got the angle and the reflex angle, both clamped to 0...360. We just need to decide, which one to choose. So just do a smaller or larger than 0 comparison and feed that int a Pick'n'Choose along with both angles.
Thanks!
I use the pick'n'choose component like you described it to get the angle between u and v. In my example file i actually get the opposite one but that should not be a problem.
From this angle the eval component computes the angle between the faces by subtracting 180° (or subtract the angle from 180° if you picked the other angle in the previous step). The problem is that you get e.g. -75° instead of 285°.
For further calculations a negative angle would not be a problem but is not common for dimensioning. So i add 360° and use the modulo operation to get only positive angles. Of course you can do that also with pick'n'choose.
Hannes,
thanks for your comment.
I am trying to know something about time consuming in this component, but the profiler widget doesn't show any information on it.
Does it signify that the time consuming it is not relevant for that component in my case?
TJO,
thanks for your reply and detailed explanation!
I understood the idea. Works fine.
Thank you very much!
Hi Thomas,
I found this post because I'm facing a similar problem. I like the idea of introducing a third vector and calculate the angle between them. I have implemented your "anglebetweenfaces_idea" in my task.
I have the problem that for some faces, u >90° related to w and v<90°. So I get the angle and the reflex angle between this two faces.
Please see the red grouped componants in the gh file.
Has someone an idea how I can get rid of the two different angles? Maybe by comparing the angle between u-w and v-w?
Thanks and best regards,
Alex
forgot to attach the gh file.
This old discussion may be useful if you've got a BRep with all the surfaces joined (thus a consistent orientation of the surface normals). Face topology for surfaces is a lot more straightforward these days with add-on's like Sandbox.
http://www.grasshopper3d.com/forum/topics/q-specific-pairings-from
Added by Naoto Tamura 0 Comments 0 Likes
Added by Naoto Tamura 3 Comments 1 Like
© 2018 Created by Scott Davidson. Powered by