/** * @brief Given a list of lines within the original image, compute their * horizontal Y pixels or vertical X pixels within the rotated image. * * Input: * origWidth,origHeight = width and height of original image * portBitmap,portWidth,portHeight = rotated image * slope = collection of line segments of equal slope * * Output: * longlenverts,longlenhorzs = filled in to indicate where lat/lon lines * are in the rotated image */ public static void ComputeVertHorzLatLons (Slope slope) { // scan through each line of the given slope foreach (LongLine line in slope.GetLongLines ()) { if (!line.IsValid ()) continue; // rotate the line's endpoints from original image coords to rotated image coords XY begRot = RotateImagePoint (line.begx, line.begy, latLonSlopeX, latLonSlopeY); XY endRot = RotateImagePoint (line.endx, line.endy, latLonSlopeX, latLonSlopeY); int xdiff = begRot.x - endRot.x; int ydiff = begRot.y - endRot.y; if (xdiff < 0) xdiff = -xdiff; if (ydiff < 0) ydiff = -ydiff; // small X difference means vertical if (xdiff <= ydiff / 16) { int xavg = (begRot.x + endRot.x) / 2; if ((xavg >= 0) && (xavg < portWidth)) { longlenverts[xavg] += ydiff; } } // small Y difference means horizontal if (ydiff <= xdiff / 16) { int yavg = (begRot.y + endRot.y) / 2; if ((yavg >= 0) && (yavg < portHeight)) { longlenhorzs[yavg] += xdiff; } } } }