Mercurial > dive4elements > gnv-client
comparison gnv-artifacts/src/main/java/de/intevation/gnv/math/LinearMetrics.java @ 361:aec85d00d82c
Added code to do 2D interpolations along a digitied track on the map.
Not connected to the transition model, yet.
gnv-artifacts/trunk@435 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 15 Dec 2009 22:25:53 +0000 |
parents | ee760729f6b8 |
children | 6cff63d0c434 |
comparison
equal
deleted
inserted
replaced
360:ee760729f6b8 | 361:aec85d00d82c |
---|---|
1 package de.intevation.gnv.math; | 1 package de.intevation.gnv.math; |
2 | 2 |
3 import java.awt.geom.Point2D; | 3 import com.vividsolutions.jts.geom.Coordinate; |
4 | |
5 import de.intevation.gnv.math.LinearToMap.Metrics; | |
6 import de.intevation.gnv.math.LinearToMap.Interpolator; | |
7 | 4 |
8 /** | 5 /** |
9 * @author Sascha L. Teichmann | 6 * @author Sascha L. Teichmann |
10 */ | 7 */ |
11 public final class LinearMetrics | 8 public final class LinearMetrics |
20 private double mx; | 17 private double mx; |
21 private double bx; | 18 private double bx; |
22 private double my; | 19 private double my; |
23 private double by; | 20 private double by; |
24 | 21 |
25 public LinearInterpolator(Point2D p1, Point2D p2) { | 22 public LinearInterpolator(Coordinate p1, Coordinate p2) { |
26 | 23 |
27 /* | 24 /* |
28 I) p1.x = 0*m + bx | 25 I) p1.x = 0*m + bx |
29 II) p2.x = 1*m + bx | 26 II) p2.x = 1*m + bx |
30 | 27 |
33 p2.x = m + p1.x | 30 p2.x = m + p1.x |
34 | 31 |
35 mx = p2.x - p1.x | 32 mx = p2.x - p1.x |
36 */ | 33 */ |
37 | 34 |
38 bx = p1.getX(); | 35 bx = p1.x; |
39 mx = p2.getX() - bx; | 36 mx = p2.x - bx; |
40 | 37 |
41 by = p1.getY(); | 38 by = p1.y; |
42 my = p2.getY() - by; | 39 my = p2.y - by; |
43 } | 40 } |
44 | 41 |
45 public void interpolate(double t, Point2D v) { | 42 public void interpolate(double t, Coordinate v) { |
46 double x = t*mx + bx; | 43 v.x = t*mx + bx; |
47 double y = t*my + by; | 44 v.y = t*my + by; |
48 v.setLocation(x, y); | |
49 } | 45 } |
50 } // class LinearInterpolator | 46 } // class LinearInterpolator |
51 | 47 |
52 private LinearMetrics() { | 48 private LinearMetrics() { |
53 } | 49 } |
54 | 50 |
55 public double distance(Point2D p1, Point2D p2) { | 51 public double distance(Coordinate p1, Coordinate p2) { |
56 return p1.distance(p2); | 52 return p1.distance(p2); |
57 } | 53 } |
58 | 54 |
59 public Interpolator getInterpolator(Point2D p1, Point2D p2) { | 55 public Interpolator getInterpolator(Coordinate p1, Coordinate p2) { |
60 return new LinearInterpolator(p1, p2); | 56 return new LinearInterpolator(p1, p2); |
61 } | 57 } |
62 } | 58 } |
63 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: | 59 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8: |