# Find angles between list of sorted vertices using vertex.co.angle()

I am trying to use the technique described here Python: Calculate angle between vertices to determine the angles between a list of vertices that is sorted left to right on the x axis

        mylen2 = len(vertices)

if(mylen2 > 1):
a1 = vertices[mylen2-1].co.angle(vertices[mylen2-2].co)

if a1 > pi * 0.5:
a1 = pi - a1
print("{:.2f} degrees".format(degrees(a1)))


My output looks like this:

but my vertices are like this:

I can't imagine these angles are all less than 10 degrees especially since many appear to be on a 45 degree angle.

How can I correctly find the angles for a list of vertices in degrees?

Vert co as a vector is from origin point.

Diagram where the red ico is the origin of a mesh and the other icos are the vertices.

Question code is calculating the angle designated as alpha above between the vectors defined by the two vertex coordinates.

It appears you are after (beta) the angle between the vector made from two verts

vec = verts[i].co - verts[i - 1].co


and the x axis Vector((1, 0, 0)).angle(vec) or if the points do not all lie on same XZ plane, the projection of vec onto the XY plane containing point verts[i - 1].co.

Example from python console, consider vec = Vector((1, 1, 1)) ie this is the result when subtracting i-1th vert from ith. Meaning if you travel (1, 1, 1) from vert[i-1] you will be at the location of vert[i]

>>> vec = Vector((1, 1, 1))
>>> x_axis = Vector((1, 0, 0))


Angle between 3d vectors

>>> degrees(x_axis.angle(vec))
54.735612876297274


To project as 2d vectors onto Y=constant plane, can get the signed angle between the 2d vectors ignoring y.

>>> degrees(x_axis.xz.angle_signed(vec.xz))
-45.00000125223908

• the vertices are all on y=0 – bigcodeszzer Sep 15 '20 at 5:37
• Okay. I get that co gets the angle from 0,0 but how do I get the angle between two of the vertices? – bigcodeszzer Sep 15 '20 at 5:41
• There is no angle between two points. without some other reference vector. Have explained what you are calculating in question (alpha) and how to get what I assume you are after the angle beta. Can't go north west from point A to point B without having some reference of what north and west is. Just looked at link posted in question, also points out that a reference vector is required. – batFINGER Sep 15 '20 at 5:45
• or to put this another way, have used grease pencil to demonstrate the angles alpha and beta. Edit your question with diagram of expected "angle between two vertices". – batFINGER Sep 15 '20 at 6:17
• yes beta. The angle between the two points. – bigcodeszzer Sep 15 '20 at 19:36