/**
  * If edge point [x, y] in array [x0, y0, x1, y1, ...] is outside of the image bound rectangle,
  * clamps it to the edge of the rectangle.
  *
  * @param imageBound the rectangle to clamp edge points to.
  * @param array an array of points to clamp to the rectangle, gets set to the clamped values.
  */
 public static void getEdgePoints(RectF imageBound, float[] array) {
   if (array.length < 2) return;
   for (int x = 0; x < array.length; x += 2) {
     array[x] = GeometryMathUtils.clamp(array[x], imageBound.left, imageBound.right);
     array[x + 1] = GeometryMathUtils.clamp(array[x + 1], imageBound.top, imageBound.bottom);
   }
 }
 /**
  * Takes a point and the corners of a rectangle and returns the two corners representing the side
  * of the rectangle closest to the point.
  *
  * @param point the point which is being checked
  * @param corners the corners of the rectangle
  * @return two corners representing the side of the rectangle
  */
 public static float[] closestSide(float[] point, float[] corners) {
   int len = corners.length;
   float oldMag = Float.POSITIVE_INFINITY;
   float[] bestLine = null;
   for (int i = 0; i < len; i += 2) {
     float[] line = {
       corners[i], corners[(i + 1) % len],
       corners[(i + 2) % len], corners[(i + 3) % len]
     };
     float mag =
         GeometryMathUtils.vectorLength(
             GeometryMathUtils.shortestVectorFromPointToLine(point, line));
     if (mag < oldMag) {
       oldMag = mag;
       bestLine = line;
     }
   }
   return bestLine;
 }
 public Bitmap renderGeometryIcon(Bitmap bitmap, ImagePreset preset) {
   return GeometryMathUtils.applyGeometryRepresentations(preset.getGeometryFilters(), bitmap);
 }