1171{
1172 double d1 = 1000000000.0, d2, d3, d_nearest;
1175
1176
1178 {
1179 if (closest)
1180 *closest = e->
start;
1181
1183 }
1184
1193 {
1195 }
1198
1199 d_nearest = d1;
1200 g_nearest = gk;
1201
1202 if ( d2 < d_nearest )
1203 {
1204 d_nearest = d2;
1205 g_nearest = e->
start;
1206 }
1207 if ( d3 < d_nearest )
1208 {
1209 d_nearest = d3;
1211 }
1212 if (closest)
1213 *closest = g_nearest;
1214
1215 return d_nearest;
1216}
void normalize(POINT3D *p)
Normalize to a unit vector.
void vector_scale(POINT3D *n, double scale)
Scale a vector out by a factor.
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Convert cartesian coordinates on unit sphere to spherical coordinates.
int edge_point_in_cone(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *p)
Returns true if the point p is inside the cone defined by the two ends of the edge e.
void robust_cross_product(const GEOGRAPHIC_POINT *p, const GEOGRAPHIC_POINT *q, POINT3D *a)
Computes the cross product of two vectors using their lat, lng representations.
static void vector_difference(const POINT3D *a, const POINT3D *b, POINT3D *n)
Calculate the difference of two vectors.
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
static double dot_product(const POINT3D *p1, const POINT3D *p2)
Convert cartesian coordinates on unit sphere to lon/lat coordinates static void cart2ll(const POINT3D...
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesian coordinates on unit sphere.
int geographic_point_equals(const GEOGRAPHIC_POINT *g1, const GEOGRAPHIC_POINT *g2)
Point in spherical coordinates on the world.