pointFromTo3D static method
Calculate the point length
distance from point from
, moving towards point to
in a 3-dimensional plane.
Implementation
static GeoCoordinate pointFromTo3D(
GeoCoordinate from, GeoCoordinate to, double length) {
if (from == to) return from; // from and to are the same point.
double deltay = (to.y - from.y);
double deltax = (to.x - from.x);
double deltaz = (to.z - from.z);
double deltah = sqrt(pow(deltax, 2) + pow(deltay, 2) + pow(deltaz, 2));
double factor = length / deltah;
return GeoCoordinate(from.x + factor * deltax, from.y + factor * deltay,
from.z + factor * deltaz);
}