CartesianGeometricUtilities { public static Tuple2D bottomCenterAndScale(Tuple2D toScale, int width, int height) { double newX = centerAndScale(toScale.x, width); double newY = bottomScale(toScale.y, height); assert !Double.isNaN(newX) : "newX is NaN! width="+width+", height="+height+", toScale="+toScale; assert !Double.isNaN(newY) : "newY is NaN! width="+width+", height="+height+", toScale="+toScale; return new Tuple2D(newX, newY); }  static Tuple2D centerAndScale(Tuple2D toScale, int width, int height); static Vertex centerAndScale(Vertex toScale, int width, int height, int depth); static double centerAndScale(double toScale, int maxDimension); static Tuple2D Bottom1DCenterAndScale(Tuple2D toScale, int width, int height); static Tuple2D bottomCenterAndScale(Tuple2D toScale, int width, int height); static double bottomScale(double toScale, int maxDimension); static double shortestDistanceToLineSegment(ILocated2D p1, ILocated2D l1, ILocated2D l2); static double shortestDistanceToLineSegment(double x, double y, double x1, double x2, double y1, double y2); static double euclideanDistance(ArrayList<Double> x1, ArrayList<Double> x2); static double[] polarToCartesian(double r, double theta); static double signedAngleFromSourceHeadingToTarget(ILocated2D source, ILocated2D target, double sourceRads); static double signedAngleDifference(ILocated2D v1, ILocated2D v2); static double signedAngleDifference(double rad1, double rad2); static boolean sourceHeadingTowardsTarget(double sourceRadians, ILocated2D source, ILocated2D target,
			double allowance); static boolean onSideOf(ILocated2D source, double sourceRadians, ILocated2D other, boolean right); static double restrictRadians(double rads);  }
@Test public void testBottomCenterAndScale() { Tuple2D pair = new Tuple2D(1.5, .5); int width = 2; int height = 3; Tuple2D scaledPair = CartesianGeometricUtilities.bottomCenterAndScale(pair, width, height); assertTrue(scaledPair.x >= -1 && scaledPair.y <= 1); Tuple2D scaledUpper = CartesianGeometricUtilities.bottomCenterAndScale(new Tuple2D(2 - 1, 3 - 1), width, height); Tuple2D properUpper = new Tuple2D(1, 1); Tuple2D scaledLower = CartesianGeometricUtilities.bottomCenterAndScale(new Tuple2D(0, 0), width, height); Tuple2D properLower = new Tuple2D(-1, 0); assertEquals(scaledUpper.x, properUpper.x, DOUBLE_THRESHOLD); assertEquals(scaledUpper.y, properUpper.y, DOUBLE_THRESHOLD); assertEquals(scaledLower.x, properLower.x, DOUBLE_THRESHOLD); assertEquals(scaledLower.y, properLower.y, DOUBLE_THRESHOLD); }