If the angle === 0 then I ignore it - but if there is an angle I want to figure out the inside angle and the corresponding outside angle.
This example returns 20.3 degrees but I’m looking for inside 200.3 degrees and outside 159.7 degrees. The second example has the inside and outside switched.
You might find it helpful to look at the code for Angular Dimension 2 or even the the original Angular Dimension plugin by @slbaumgartner (Steve Baumgartner). He wrote the code to measure the angle between two edges given three picked vertices, the middle pick being the common vertex. I think you could supply the equivalent from two planes with a common edge.
They are free, from SketchUcation Plugin Store.
I think that SU angle_between always returns an angle less than 180 so you have to figure out when to add 180.
And I see that 200.3 = 180 + 20.3.
And also that if you draw the normals in your diagram with a common vertex on the edge, you would expect to get 20.3°, not 159.7°, wouldn’t you?
If you want to get the obtuse angle, try reversing the direction of one normal.
Get the ‘.cross’ between those two vectors.
Get the cross’s Z and if it’s +/- determines the angle direction.
I there’s no cross result they are probably co-linear ?
Still looks to me that if you reverse one normal, you get 159.7° as the returned angle. Then you have to figure out whether you want that, or its complement (180 + 20.3 = 200.3° or 360 - 159.7 = 200.3°) as the result,
Of course when you look at the model you can immediately determine if you need to add 180 to the angle or subtract the angle from 180.
What I’m trying to figure out is how to do that inside a script I will play around with the cross as Tig suggests and see if that gives me what I want.
I looked at the Angular Dimension code. That part will work but I need to determine the proper vectors.
If I start with the mid point of the common edge and then draw one line on the 2 faces where each line is perpendicular to the common edge then I can get Angular Dimension to produce the correct results.
Then maybe try ‘if the intersection of the normals from the ends of the short lines you have drawn out from the edge is on the face side (of either face), use less than 180°, otherwise use the complement’?
Can you have one face the reverse of the other at the common edge? If so, I think the answer is indeterminate.
Sounds as though it should. I can’t remember the Ruby method(s) that enable you to tell whether a point is on the plane of a face, [Edit: on the face side, or the reverse side] but I’m sure there is one.