Mercurial > dive4elements > river
view flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java @ 5227:a981222b6260
ImportRiver: Preparing wst-based waterleveldifferences.
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Mon, 11 Mar 2013 15:01:05 +0100 |
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 :