STRAIGHTNESS
When is a curve straight ?
Given a curve as a sequence of pixels C = P[i] for i=0,..,k
its displacement is the (euclidean) distance between the endpoints
L{C} = d(P[0], P[k])
Its straightness is
S{C} = L{C} / ( 1 + 1/(k-1) Sum d(P[i], r) )
where r is the line between the endpoints, and d(P, r)
denotes the (euclidean) distance from the point P to r,
r: x = Px[0] + t ( Px[k] - Px[0] )
y = Py[0] + t ( Py[k] - Py[0] )
that is
(x - Px[0]) (Py[k] - Py[0] )
=
(y - Py[0]) (Px[k] - Px[0] )
The distance is
d(P, r) = (1/D) |
(Px - Px[0]) (Py[k] - Py[0] )
-
(Py - Py[0]) (Px[k] - Px[0] ) |
where D is
D = sqrt( (Px[k] - Px[0] )2 +
(Py[k] - Py[0] )2 )
Marco Corvi - Page hosted by
geocities.com.