CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    9

    Pollyline delimeter

    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
    [email protected]


  2. #2
    Join Date
    Apr 1999
    Posts
    37

    Re: Pollyline delimeter


    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;
    }





Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured