Hi!
I am trying to implement the equations presented here regarding finding a point on a given perpendicular distance from a line. Unfortunately the lines I receive are not straight. Is this due to me mixing Lat/long with regular x/y coordinates or have I done something else wrong?!
double distPoint = 0.02;
double latDiff = temp2.Latitude - temp.Latitude;
double longDiff = temp2.Longitude - temp.Longitude;
double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff);
double uLat = latDiff / length;
double uLong = longDiff / length;
double newLat1 = temp2.Latitude + (distPoint / 2) * uLat;
double newLong1 = temp2.Longitude - (distPoint / 2) * uLong;
double newLat2 = temp2.Latitude - (distPoint / 2) * uLat;
double newLong2 = temp2.Longitude + (distPoint / 2) * uLong;
Have changed the code now, and the variable names. Still receiving the fault :-(
double dist = 0.02;
double latDiff = secondTestPoint.Latitude - firstTestPoint.Latitude;
double longDiff = secondTestPoint.Longitude - firstTestPoint.Longitude;
double length = Math.Sqrt(latDiff * latDiff + longDiff * longDiff);
double uLat = latDiff / length;
double uLong = longDiff / length;
double newLat1 = secondTestPoint.Latitude + (dist / 2) * uLong;
double newLong1 = secondTestPoint.Longitude - (dist / 2) * uLat;
double newLat2 = secondTestPoint.Latitude - (dist / 2) * uLong;
double newLong2 = secondTestPoint.Longitude + (dist / 2) * uLat;
Here are the variable values:
latDiff = -0.0046187639236450195
longDiff = -0.0058203935623168945
length = 0.0074303405980227239
uLat = -0.62160864131505777
uLong = -0.78332796263279647
newLat1 = 58.39273776863341
newLong1 = 15.558675147558933
newLat2 = 58.408404327886061
newLong2 = 15.546242974732632
UPDATE: I have come to the conclusion that the fault is due to lat/long issues. It seems reasonable that it would generate faults to think that the lat/long are equivalent to squares when they in fact are not. Especially when working with northern europe.