@Test public void testDistributePoints() throws Exception { int[][] distribPnts_ACTUAL = MathUtils.distributePoints(numOfPnts, winForDistribution); for (int i = 0; i < distribPnts_ACTUAL.length; i++) { Assert.assertArrayEquals(distributedPoints_EXPECTED[i], distribPnts_ACTUAL[i]); } }
public static int[][] distributePoints(final int numOfPoints, final Window window) { final float lines = window.lines(); final float pixels = window.pixels(); int[][] result = new int[numOfPoints][2]; float winP = (float) Math.sqrt(numOfPoints / (lines / pixels)); float winL = numOfPoints / winP; if (winL < winP) { winL = winP; } final int winL_int = (int) Math.floor(winL); final float deltaLin = (lines - 1) / (float) (winL_int - 1); final int totalPix = (int) Math.floor(pixels * winL_int); final float deltaPix = (float) (totalPix - 1) / (float) (numOfPoints - 1); float pix = -deltaPix; float lin; int lCounter = 0; for (int i = 0; i < numOfPoints; i++) { pix += deltaPix; while (Math.floor(pix) >= pixels) { pix -= pixels; lCounter++; } lin = lCounter * deltaLin; result[i][0] = (int) (Math.floor(lin) + window.linelo); result[i][1] = (int) (Math.floor(pix) + window.pixlo); } return result; }
MathUtils { public static int[][] distributePoints(final int numOfPoints, final Window window) { final float lines = window.lines(); final float pixels = window.pixels(); int[][] result = new int[numOfPoints][2]; float winP = (float) Math.sqrt(numOfPoints / (lines / pixels)); float winL = numOfPoints / winP; if (winL < winP) { winL = winP; } final int winL_int = (int) Math.floor(winL); final float deltaLin = (lines - 1) / (float) (winL_int - 1); final int totalPix = (int) Math.floor(pixels * winL_int); final float deltaPix = (float) (totalPix - 1) / (float) (numOfPoints - 1); float pix = -deltaPix; float lin; int lCounter = 0; for (int i = 0; i < numOfPoints; i++) { pix += deltaPix; while (Math.floor(pix) >= pixels) { pix -= pixels; lCounter++; } lin = lCounter * deltaLin; result[i][0] = (int) (Math.floor(lin) + window.linelo); result[i][1] = (int) (Math.floor(pix) + window.pixlo); } return result; } }
MathUtils { public static int[][] distributePoints(final int numOfPoints, final Window window) { final float lines = window.lines(); final float pixels = window.pixels(); int[][] result = new int[numOfPoints][2]; float winP = (float) Math.sqrt(numOfPoints / (lines / pixels)); float winL = numOfPoints / winP; if (winL < winP) { winL = winP; } final int winL_int = (int) Math.floor(winL); final float deltaLin = (lines - 1) / (float) (winL_int - 1); final int totalPix = (int) Math.floor(pixels * winL_int); final float deltaPix = (float) (totalPix - 1) / (float) (numOfPoints - 1); float pix = -deltaPix; float lin; int lCounter = 0; for (int i = 0; i < numOfPoints; i++) { pix += deltaPix; while (Math.floor(pix) >= pixels) { pix -= pixels; lCounter++; } lin = lCounter * deltaLin; result[i][0] = (int) (Math.floor(lin) + window.linelo); result[i][1] = (int) (Math.floor(pix) + window.pixlo); } return result; }  }
MathUtils { public static int[][] distributePoints(final int numOfPoints, final Window window) { final float lines = window.lines(); final float pixels = window.pixels(); int[][] result = new int[numOfPoints][2]; float winP = (float) Math.sqrt(numOfPoints / (lines / pixels)); float winL = numOfPoints / winP; if (winL < winP) { winL = winP; } final int winL_int = (int) Math.floor(winL); final float deltaLin = (lines - 1) / (float) (winL_int - 1); final int totalPix = (int) Math.floor(pixels * winL_int); final float deltaPix = (float) (totalPix - 1) / (float) (numOfPoints - 1); float pix = -deltaPix; float lin; int lCounter = 0; for (int i = 0; i < numOfPoints; i++) { pix += deltaPix; while (Math.floor(pix) >= pixels) { pix -= pixels; lCounter++; } lin = lCounter * deltaLin; result[i][0] = (int) (Math.floor(lin) + window.linelo); result[i][1] = (int) (Math.floor(pix) + window.pixlo); } return result; }  static boolean isEven(long value); static boolean isOdd(long value); static boolean isPower2(long value); static double rad2deg(double valueInRadians); static double deg2rad(double valueInDegrees); static int[][] distributePoints(final int numOfPoints, final Window window); static double[][] distributePointsDoubles(final int numOfPoints, final Window window); static double[] increment(int m, double begin, double pitch); static double[][] increment(int m, int n, double begin, double pitch); static DoubleMatrix ramp(final int nRows, final int nColumns); static DoubleMatrix lying(DoubleMatrix inMatrix); static int randomIntInRange(int min, int max); @Deprecated static double sqrt(double value); @Deprecated static double sqr(double value); }
MathUtils { public static int[][] distributePoints(final int numOfPoints, final Window window) { final float lines = window.lines(); final float pixels = window.pixels(); int[][] result = new int[numOfPoints][2]; float winP = (float) Math.sqrt(numOfPoints / (lines / pixels)); float winL = numOfPoints / winP; if (winL < winP) { winL = winP; } final int winL_int = (int) Math.floor(winL); final float deltaLin = (lines - 1) / (float) (winL_int - 1); final int totalPix = (int) Math.floor(pixels * winL_int); final float deltaPix = (float) (totalPix - 1) / (float) (numOfPoints - 1); float pix = -deltaPix; float lin; int lCounter = 0; for (int i = 0; i < numOfPoints; i++) { pix += deltaPix; while (Math.floor(pix) >= pixels) { pix -= pixels; lCounter++; } lin = lCounter * deltaLin; result[i][0] = (int) (Math.floor(lin) + window.linelo); result[i][1] = (int) (Math.floor(pix) + window.pixlo); } return result; }  static boolean isEven(long value); static boolean isOdd(long value); static boolean isPower2(long value); static double rad2deg(double valueInRadians); static double deg2rad(double valueInDegrees); static int[][] distributePoints(final int numOfPoints, final Window window); static double[][] distributePointsDoubles(final int numOfPoints, final Window window); static double[] increment(int m, double begin, double pitch); static double[][] increment(int m, int n, double begin, double pitch); static DoubleMatrix ramp(final int nRows, final int nColumns); static DoubleMatrix lying(DoubleMatrix inMatrix); static int randomIntInRange(int min, int max); @Deprecated static double sqrt(double value); @Deprecated static double sqr(double value);  }