Click to See Complete Forum and Search --> : Pollyline delimeter


Vitor Sarabando
May 21st, 1999, 03:43 AM
I'me trying to solve a problem.
I have several points of a figure and i have to get to pollyline (with the smallest number of point's) that sorrounds the point's. How can that be acheived ??
Any clues ???
Thanks in advance
vss@liscont.pt

tangzibo
May 24th, 1999, 01:15 AM
int minPos = 0;
int minY = points[0].y;
for( int j = 1 ; j < nPointNum ; j++ )
{
if( points[j].y < minY )
{
minY = points[j].y;
minPos = j;
}
}

AddtoPolyLine( points[minPos]);

CPoint p1 = points[minPos];
CPoint firstPoint = p1;
CPoint p2;
p2.x = p1.x + 1;
p2.y = p1.y;
int curPos = minPos;
while(1)
{
double minAngle = 360.0;
for( j = 0 ; j < nPointNum ; j++ )
{
if( j == curPos )
continue;
double angle = TwoLineAngle( p1, p2, p1, points[j]);
if( angle < minAngle )
{
minAngle = angle;
minPos = j;
}
}

AddtoPolyLine( points[minPos]);
p2 = p1;
p1 = points[minPos];
curPos = minPos;
if( p1 == firstPoint )
break;
}