Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/geom/Lines.java @ 8856:5e38e2924c07 3.2.x
Fix code style.
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Thu, 18 Jan 2018 20:12:01 +0100 |
parents | af13ceeba52a |
children | 0a5239a1e46e |
comparison
equal
deleted
inserted
replaced
8855:d7c005e12af0 | 8856:5e38e2924c07 |
---|---|
41 /** | 41 /** |
42 * Calculate area of polygon with four vertices. | 42 * Calculate area of polygon with four vertices. |
43 * @return area of polygon with four vertices. | 43 * @return area of polygon with four vertices. |
44 */ | 44 */ |
45 public static double area(Point2D p1, Point2D p2, Point2D p3, Point2D p4) { | 45 public static double area(Point2D p1, Point2D p2, Point2D p3, Point2D p4) { |
46 double[] x = new double[] {p1.getX(), p2.getX(), p3.getX(), p4.getX(), p1.getX() }; | 46 double[] x = new double[] { |
47 double[] y = new double[] {p1.getY(), p2.getY(), p3.getY(), p4.getY(), p1.getY() }; | 47 p1.getX(), p2.getX(), p3.getX(), p4.getX(), p1.getX() }; |
48 double[] y = new double[] { | |
49 p1.getY(), p2.getY(), p3.getY(), p4.getY(), p1.getY() }; | |
48 double area = 0d; | 50 double area = 0d; |
49 for (int i=0; i <4; i++) { | 51 for (int i=0; i <4; i++) { |
50 area += (x[i] * y[i+1]) - (x[i+1] * y[i]); | 52 area += (x[i] * y[i+1]) - (x[i+1] * y[i]); |
51 } | 53 } |
52 return Math.abs(area * 0.5d); | 54 return Math.abs(area * 0.5d); |
86 * @param points the points describing the river bed. | 88 * @param points the points describing the river bed. |
87 * @param waterLevel the height of the horizontal water line. | 89 * @param waterLevel the height of the horizontal water line. |
88 * @return A list of Lines representing the water surface and the | 90 * @return A list of Lines representing the water surface and the |
89 * calculated area between water surface and river bed. | 91 * calculated area between water surface and river bed. |
90 */ | 92 */ |
91 public static ListWithArea fillWater(List<Point2D> points, double waterLevel) { | 93 public static ListWithArea fillWater( |
92 | 94 List<Point2D> points, |
95 double waterLevel | |
96 ) { | |
93 boolean debug = log.isDebugEnabled(); | 97 boolean debug = log.isDebugEnabled(); |
94 | 98 |
95 if (debug) { | 99 if (debug) { |
96 log.debug("fillWater"); | 100 log.debug("fillWater"); |
97 log.debug("----------------------------"); | 101 log.debug("----------------------------"); |
220 boolean p2W = Math.abs(waterLevel - p2.getY()) < EPSILON; | 224 boolean p2W = Math.abs(waterLevel - p2.getY()) < EPSILON; |
221 | 225 |
222 // TODO trigger area calculation | 226 // TODO trigger area calculation |
223 if (p1W || p2W) { | 227 if (p1W || p2W) { |
224 if (debug) { | 228 if (debug) { |
225 log.debug("water hits vertex: " + p1 + " " + p2 + " " + mode); | 229 log.debug("water hits vertex: " |
230 + p1 + " " + p2 + " " + mode); | |
226 } | 231 } |
227 if (p1W && p2W) { // parallel to water -> dry | 232 if (p1W && p2W) { // parallel to water -> dry |
228 log.debug("water hits both vertices"); | 233 log.debug("water hits both vertices"); |
229 if (mode == Mode.WET) { | 234 if (mode == Mode.WET) { |
230 result.add(new Line2D.Double( | 235 result.add(new Line2D.Double( |