I have an array of points:
Point[] line; // { Point(1,1), Point(2,3), Point(1,1) }
Assuming Point has the relevant operators, what's the most linq-y way of computing the length of this line?
My best effort so far is:
float length = Enumerable.Range(0, line.Length-2)
.Select(pointIndex => (line[pointIndex+1] - line[pointIndex]).Magnitude)
.Sum();
Seems like there's a lot of subscripting in there though.
I would think there's a way to do something like this pseudocode:
float length = line.PairwiseMap(p1, p2 => (p2 - p1).Magnitude).Sum();
?