Segment3.pm - third idea of segmentation

use Segment3; Segment3::setup(area_threshold=>100,length_threshold=>10); @stroke=qw(x0 y0 x1 y1 x2 y2 ...); $vectors=Segment3::segment(\@stroke);

This modules implements a quite robust and effective way of transforming a list of coordinates into a list of vectors.

Call this function to set the area threshold for bisecting a vector, and the length threshold for not bisecting it.

This function creates a list of vectors in the following way:

- Take a vector from the first point to the last
- if the length of the stroke between the vector's extremes is less that $Segment3::length_threshold, return the vector unchanged
- sum the distance of every point between the extremes of the vector from the vector itself
- if the sum is greater than $Segment3::area_threshold, split the vector (a,b) into (a,c) and (c,b), where c is the point fartest from (a,b)
- go down recursively from step 2 on both vectors

Returns the length of a vector

Given a list of points `$stroke`

and two indices in that list `$first`

and `$last`

, returns:

the length of the vector between the

`$first`

and the`$last`

point in`$stroke`

the sum of distances from said vector of points between

`$first`

and`$last`

in`$stroke`

the length of the stroke between the two points

This code is copyright (C) 2002 Gianni Ceccarelli Released under the GNU LGPL, version 2.1