From ca47e798c33db76722052bf5cc2ddd5911623c38 Mon Sep 17 00:00:00 2001 From: Victor Date: Sat, 22 Feb 2014 15:28:20 +0200 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=9B=D0=A0-1=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0?= =?UTF-8?q?=D0=BD=D1=82=208?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gm/LR_1_v8.java | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) 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]); } } }