Mercurial > dive4elements > river
view flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java @ 6991:b656568bcb2b dc-km-filter-rr
Closing inaktive branch "dc-km-filter-rr".
author | Bernhard Reiter <bernhard@intevation.de> |
---|---|
date | Wed, 11 Sep 2013 15:40:51 +0200 |
parents | ce6b9945bf8e |
children |
line wrap: on
line source
package de.intevation.flys.importer.parsers.tim; /** Two coordinates and a helper. */ public class Line { public Coordinate a; public Coordinate b; public Line() { } public Line(Coordinate a, Coordinate b) { this.a = a; this.b = b; } /** Project coordinate to line. */ public double distanceToFirst(Coordinate c) { double nx = b.x - a.x; double ny = b.y - a.y; double len = Math.sqrt(nx*nx + ny*ny); nx /= len; ny /= len; double px = c.x - a.x; double py = c.y - a.y; return nx*px + ny*py; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :