comparison backend/src/main/java/org/dive4elements/river/importer/parsers/tim/Line.java @ 5838:5aa05a7a34b7

Rename modules to more fitting names.
author Sascha L. Teichmann <teichmann@intevation.de>
date Thu, 25 Apr 2013 15:23:37 +0200
parents flys-backend/src/main/java/org/dive4elements/river/importer/parsers/tim/Line.java@18619c1e7c2a
children 4dd33b86dc61
comparison
equal deleted inserted replaced
5837:d9901a08d0a6 5838:5aa05a7a34b7
1 package org.dive4elements.river.importer.parsers.tim;
2
3 /** Two coordinates and a helper. */
4 public class Line {
5
6 public Coordinate a;
7 public Coordinate b;
8
9 public Line() {
10 }
11
12 public Line(Coordinate a, Coordinate b) {
13 this.a = a;
14 this.b = b;
15 }
16
17 /** Project coordinate to line. */
18 public double distanceToFirst(Coordinate c) {
19
20 double nx = b.x - a.x;
21 double ny = b.y - a.y;
22
23 double len = Math.sqrt(nx*nx + ny*ny);
24
25 nx /= len;
26 ny /= len;
27
28 double px = c.x - a.x;
29 double py = c.y - a.y;
30
31 return nx*px + ny*py;
32 }
33 }
34 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org