> Example: > > Your coordinates (G): (2, 3) > Your road segment (AB): (1, 1) -> (4, 5) > > Therefore you get: > Function for all points on AB: (1, 1) + t*(3, 4) (for 0<=t<=1) > Normal vector to AB (n): (-4, 3) > Unified normal vector to AB (n0): (-4/5, 3/5) = (-0.8, 0.6) > > > You can use the hesse normal form to calculate the distance (which is the > easier solution): > > Hesse normal form: n0 * (X - A) (for X is any point on AB) > Our Hesse normal form of that line: (-0.8, 0.6) * (X - (1, 1)) = 0 > > Distance form: | AG * n0 | ( * being a scalar product ) > Our distance: | (1, 2) * (-0.8, 0.6) | = | -0.8 + 1.2 | > > -> distance: 0.4
The length of a vector (a,b) is sqrt(a^2 + b^2), not abs(a+b)! Thus |(1,2) * (-0.8,0.6)| = |-0.8,1.2| = sqrt(0.64+1.44) = sqrt(2.08) ~ 1.44 -- GMX DSL: Internet-, Telefon- und Handy-Flat ab 19,99 EUR/mtl. Bis zu 150 EUR Startguthaben inklusive! http://portal.gmx.net/de/go/dsl _______________________________________________ dev mailing list dev@openstreetmap.org http://lists.openstreetmap.org/listinfo/dev