# How to get angles along a line?

What is the best way to get the angles along a line? I have tried this for example:

points = Accumulate[RandomReal[{-0.05, 0.1}, {100, 2}]];
PolygonAngle[Polygon[points]]


However, this means I have to remove the two end points. It's also not good in the following scenario:

points = {{0, 0}, {0, 1}, {0, 2}};
PolygonAngle[Polygon[points]]


I hoped this might work, but it doesn't:

MovingMap[VectorAngle[(#[[1]] - #[[2]]), (#[[3]] - #[[2]])] &, points, 2]


Is there a better way? I need the angles to be in $$[0,\pi]$$ and intrinsic.

I'd try something like this:

BlockMap[PlanarAngle, points, 3, 1]


But you said you want the points to be in [0,2 Pi], so if that means you want to include angles larger than Pi, then I think you'll need to decide on a standard orientation first. Maybe like this:

BlockMap[PlanarAngle[#, "Clockwise"] &, points, 3, 1]

• 2pi was a mistake. I meant 0,pi so the orientation won't matter. Commented Mar 26 at 17:57
VectorAngle[#[[2]] - #[[1]], #[[3]] - #[[2]]] & /@
Partition[points, 3, 1]


For example,

Clear[points];
points = {{0, 0}, {0, 1}, {0, 2}};
VectorAngle[#[[2]] - #[[1]], #[[3]] - #[[2]]] & /@
Partition[points, 3, 1]


{0}.

{0} instead of {π} means that the Line[points] does not change the direction.

• Compare with the results of #[[2]] - #[[1]] and #[[1]] - #[[2]], we only need to use π to subtract one of them.
list1 = VectorAngle[#[[2]] - #[[1]], #[[3]] - #[[2]]] & /@
Partition[points, 3, 1];
list2 = VectorAngle[#[[1]] - #[[2]], #[[3]] - #[[2]]] & /@
Partition[points, 3, 1];

True.