From 20bef6e26d948698398bd16aeab8c9e6b89110e4 Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Thu, 22 Aug 2019 20:01:40 -0400 Subject: Format/import cleanup --- src/main/java/com/pau101/util/BezierUtils.java | 53 ++++++++++---------------- 1 file changed, 20 insertions(+), 33 deletions(-) (limited to 'src/main/java/com/pau101/util/BezierUtils.java') diff --git a/src/main/java/com/pau101/util/BezierUtils.java b/src/main/java/com/pau101/util/BezierUtils.java index 27b82d5..cc57252 100755 --- a/src/main/java/com/pau101/util/BezierUtils.java +++ b/src/main/java/com/pau101/util/BezierUtils.java @@ -11,14 +11,13 @@ public final class BezierUtils { * Compute the value of all nth degree Bernstein polynomials. * * @param curveDegree - * : degree of curve + * : degree of curve * @param t - * : curve parameter on interval [0,1] + * : curve parameter on interval [0,1] * @param scalars - * : curveDegree + 1 Bernstein values. + * : curveDegree + 1 Bernstein values. */ - public static void allBernstein(int curveDegree, float t, - float scalars[]) { + public static void allBernstein(int curveDegree, float t, float scalars[]) { int j, k; float nt = 1 - t; float saved; @@ -38,16 +37,15 @@ public final class BezierUtils { * Compute point of nth degree Bezier curve. * * @param controlPoints - * : curveDegree + 1 control points + * : curveDegree + 1 control points * @param curveDegree - * : degree of curve + * : degree of curve * @param t - * : curve parameter on interval [0,1] + * : curve parameter on interval [0,1] * @param point - * : resulting point + * : resulting point */ - public static void pointOnBezierCurve(float controlPoints[][], - int curveDegree, float t, float point[]) { + public static void pointOnBezierCurve(float controlPoints[][], int curveDegree, float t, float point[]) { float scalars[] = new float[curveDegree + 1]; int k; allBernstein(curveDegree, t, scalars); @@ -60,51 +58,40 @@ public final class BezierUtils { } /** - * Compute an approximate length of a Bezier curve given the - * control points. + * Compute an approximate length of a Bezier curve given the control points. * * @param controlPoints - * : control points of a Bezier curve + * : control points of a Bezier curve * @return the approximate length */ public static float approximateLength(float controlPoints[][]) { float length = 0; for (int i = 0; i < controlPoints.length - 1; i++) { - float xDif = controlPoints[i + 1][0] - - controlPoints[i][0]; - float yDif = controlPoints[i + 1][1] - - controlPoints[i][1]; - float zDif = controlPoints[i + 1][2] - - controlPoints[i][2]; - length += Math.sqrt(xDif * xDif + yDif * yDif - + zDif * zDif); + float xDif = controlPoints[i + 1][0] - controlPoints[i][0]; + float yDif = controlPoints[i + 1][1] - controlPoints[i][1]; + float zDif = controlPoints[i + 1][2] - controlPoints[i][2]; + length += Math.sqrt(xDif * xDif + yDif * yDif + zDif * zDif); } return length; } - public static int tesselationSegementsForLength(float length, - float scale) { + public static int tesselationSegementsForLength(float length, float scale) { float noLessThan = 10 * scale; float segs = length * scale / 30F; - return (int) Math.ceil(Math.sqrt(segs * segs * 0.6 - + noLessThan * noLessThan)); + return (int) Math.ceil(Math.sqrt(segs * segs * 0.6 + noLessThan * noLessThan)); } public static float[][] curve(float controlPoints[][]) { return curve(controlPoints, 1); } - public static float[][] curve(float controlPoints[][], - float scale) { - int count = tesselationSegementsForLength( - approximateLength(controlPoints), scale); + public static float[][] curve(float controlPoints[][], float scale) { + int count = tesselationSegementsForLength(approximateLength(controlPoints), scale); float[][] points = new float[count][3]; for (int i = 0; i < count; i++) { float t = i / (float) (count - 1); float[] point = new float[3]; - pointOnBezierCurve(controlPoints, - controlPoints.length - 1, t, - point); + pointOnBezierCurve(controlPoints, controlPoints.length - 1, t, point); points[i] = point; } return points; -- cgit v1.2.3