diff --git a/src/gm/LR_1_v8.java b/src/gm/LR_1_v8.java index 658a44c..c20b8f2 100644 --- a/src/gm/LR_1_v8.java +++ b/src/gm/LR_1_v8.java @@ -13,44 +13,50 @@ public class LR_1_v8 extends Application { new LR_1_v8(); } + private static final double ARROW_WIDTH = 0.5; + private static final double ARROW_HEIGHT = 0.2; private static final double[][] ARROW_PTS = { - {0.0, 0.5, 0.4, 0.4, 0.5}, - {0.0, 0.00, 0.2, -0.2, 0.00}, + // x, y + {0.0, 0.0}, + {ARROW_WIDTH, 0.0}, + {4d * ARROW_WIDTH / 5d, ARROW_HEIGHT}, + {4d * ARROW_WIDTH / 5d, -ARROW_HEIGHT}, + {ARROW_WIDTH, 0.0}, }; private static final double N = 30; public LR_1_v8() { - super(900, 480); + super(900, 500); setTitle("LR_1 v8"); } @Override protected void paint(GraphicsExt g) { - double x1 = 0, y1 = 2; + double x1 = 0, y1 = 2.5; for (int i = 0; i < N; i++) { - double x2 = x1 + (i / 50d); + final double scaleValue = (i / 24d); + double x2 = x1 + ARROW_WIDTH * scaleValue; double y2 = y1 + Math.sin(x2) / 5d; g.reset(); g.translate(x2, y2); g.rotate(-Math.atan2(y2 - y1, x2 - x1)); - drawArrow(g, i); - x1 = x2; + drawArrow(g, scaleValue); + x1 = x1 + ARROW_WIDTH * scaleValue; y1 = y2; } } - private void drawArrow(GraphicsExt g, int num) { - final int length = ARROW_PTS[0].length; - double[][] points = new double[2][length]; - double scale = num / 30d; + private void drawArrow(GraphicsExt g, double scaleValue) { + final int length = ARROW_PTS.length; + double[][] points = new double[length][2]; for (int i = 0; i < length; i++) { - points[0][i] = ARROW_PTS[0][i] * scale; - points[1][i] = ARROW_PTS[1][i] * scale; + points[i][0] = ARROW_PTS[i][0] * scaleValue; + points[i][1] = ARROW_PTS[i][1] * scaleValue; } - g.move(points[0][0], points[1][0]); + g.move(points[0][0], points[0][1]); for (int i = 1; i < length; i++) { - g.draw(points[0][i], points[1][i]); + g.draw(points[i][0], points[i][1]); } } }