NAME

Segment3.pm - third idea of segmentation


SYNOPSIS

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


DESCRIPTION

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


FUNCTIONS

sub setup

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

sub segment

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

1.

Take a vector from the first point to the last

2.

if the length of the stroke between the vector's extremes is less that $Segment3::length_threshold, return the vector unchanged

3.

sum the distance of every point between the extremes of the vector from the vector itself

4.

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)

5.

go down recursively from step 2 on both vectors

sub vlen

Returns the length of a vector

sub calc_area

Given a list of points $stroke and two indices in that list $first and $last, returns:


LICENSE

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


Last updated: Thu Apr 11 13:46:34 2002