Mercurial > dive4elements > river
comparison flys-backend/src/main/java/org/dive4elements/river/importer/parsers/tim/Line.java @ 5828:dfb26b03b179
Moved directories to org.dive4elements.river
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Thu, 25 Apr 2013 11:53:11 +0200 |
parents | flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java@ce6b9945bf8e |
children | 18619c1e7c2a |
comparison
equal
deleted
inserted
replaced
5827:e308d4ecd35a | 5828:dfb26b03b179 |
---|---|
1 package de.intevation.flys.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 : |