# Ruby angle_between issue

Hi guys wonder if someone can help.
I am trying to differentiate the difference between an internal corner and an external corner to get two different angles as shown in the attached image.

This is the code I am using, which is returning the same angle for all…?

``puts (sel[0].faces[0].normal.angle_between (sel[0].faces[1].normal)).radians``

Any help would be greatly appreciated.
Thanks

angle_between just checks how “close” two vectors are to each other and have no concept of negative values or values over 180 degrees. However this snippet can distinguish concave and convex edges in a mesh which can then be used to interpret the value as negative (or 360 degrees minus the original value if you want positive numbers).

More elegant solution:

``````# Counter-clockwise angle from vector2 to vector1, as seen from normal.
def angle_in_plane(vector1, vector2, normal = Z_AXIS)
Math.atan2((vector2 * vector1) % normal, vector1 % vector2)
end

def edge_angle(edge)
angle = angle_in_plane(edge.faces[0].normal, edge.faces[1].normal, edge.line[1])

# Assuming mesh is oriented, i.e. edge is reversed in exactly one out of the two
# faces. If not, the return value depends the order the faces are presented in.
edge.reversed_in?(edge.faces[0]) ? angle : -angle
end