IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 11, 2009, 6:09:52 PM (17 years ago)
Author:
eugene
Message:

modifications to support a two-pass check on the line range, limiting the initial ra,dec range to the region of the chip of interest using just the projection portion

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/magic/remove/src/Line.c

    r24380 r24382  
    225225    vertices[2].x = numCols; vertices[2].y = numRows;
    226226    vertices[3].x = 0;       vertices[3].y = numRows;
     227
     228    for (i = 0; i < 4 && found < 2; ++i)
     229    {
     230        boundLine.begin = vertices[i];
     231        boundLine.end   = vertices[(i + 1) % 4];
     232        if (LineIntercept (line, &boundLine, &tuple1, &tuple2, false, true))
     233        {
     234            if (found == 0)
     235            {
     236                clipLine.begin = tuple1;
     237                ++found;
     238            }
     239            else if (tuple1.x != clipLine.begin.x ||
     240                     tuple1.y != clipLine.begin.y)
     241            {
     242                clipLine.end = tuple1;
     243                ++found;
     244            }
     245        }
     246    }
     247   
     248    // If two endpoints are found, clip the line
     249   
     250    if (found > 1)
     251    {
     252        if (clipLine.begin.x <= clipLine.end.x)
     253        {
     254            line->begin = clipLine.begin;
     255            line->end   = clipLine.end;
     256        }
     257        else
     258        {
     259            line->begin = clipLine.end;
     260            line->end   = clipLine.begin;
     261        }
     262    }
     263    return found > 1;
     264}
     265
     266/** Clip the line between (minX,minY) and (maxX,maxY)
     267
     268    @param[in,out] line line to be clipped within the bounds
     269    @param[in] minX minimum X (columns) for the line
     270    @param[in] minY minimum Y (rows) for the line
     271    @param[in] maxX maximum X (columns) for the line
     272    @param[in] maxY maximum Y (rows) for the line
     273    @return true if line overlaps the clip boundaries           */
     274
     275bool LineClipFull (Line *line, int minX, int minY, int maxX, int maxY)
     276{
     277    unsigned int i, found = 0;
     278    Line boundLine, clipLine;
     279    strkPt tuple1, tuple2, vertices[4];
     280    vertices[0].x = minX; vertices[0].y = minY;
     281    vertices[1].x = maxX; vertices[1].y = minY;
     282    vertices[2].x = maxX; vertices[2].y = maxY;
     283    vertices[3].x = minX; vertices[3].y = maxY;
    227284
    228285    for (i = 0; i < 4 && found < 2; ++i)
Note: See TracChangeset for help on using the changeset viewer.