# Validate My Heuristic for Line Straightness?

I have a finite series of line segments, each continuous from the previous one[1]. I want to quantify how "straight" or "zig-zaggy" the run of line segments is.

My idea is the following:

1) Rotate all segments such that the first point of the first segment and the last point of the last segment are vertical with one another (ΔX = 0, ΔY > 0).

2) Walk each segment and separately sum the absolute value of both Δx and Δy for each segment. Call these absDx and absDy.

For a perfectly straight line, absDx = ΔX = 0 and absDy = ΔY.

For a series that deviates from straight, either absDx and/or absDy will be greater than 0. How much they're greater than 0 defines how zig-zaggy the lines are.

I am considering scaling the values based on ΔY such that a large ΔY requires larger absDx and absDy.

I have found other recommendations for quantifying straightness that fail to account for the idea that the line segments may double-back on themselves, or may not be of equal length and spacing.

My worry is that by simply summing values directly, I may be introducing bias in unintended ways.

[1] This represents gesture data captured from a touch screen.

That reformulation suggests simple linear regression. Then $$R^2$$ will measure the goodness of fit.
That might be a problem for nearly vertical lines, since linear regression works with the $$y$$-distances from the line. Perhaps the variant that finds the line that minimizes the orthogonal distances would be better. You can read about that at http://mathworld.wolfram.com/LeastSquaresFittingPerpendicularOffsets.html .