PostGIS  2.2.7dev-r@@SVN_REVISION@@
void normalize ( POINT3D p)

Normalize to a unit vector.

Definition at line 565 of file lwgeodetic.c.

References FP_IS_ZERO, POINT3D::x, POINT3D::y, and POINT3D::z.

Referenced by circ_center_cartesian(), circ_node_leaf_new(), clairaut_geographic(), edge_calculate_gbox_slow(), edge_distance_to_point(), edge_intersection(), edge_point_in_cone(), edge_point_side(), gbox_angular_height(), gbox_centroid(), gbox_pt_outside(), point_in_cone(), ptarray_segmentize_sphere(), sphere_angle(), test_vector_angle(), unit_normal(), vector_angle(), and vector_rotate().

566 {
567  double d = sqrt(p->x*p->x + p->y*p->y + p->z*p->z);
568  if (FP_IS_ZERO(d))
569  {
570  p->x = p->y = p->z = 0.0;
571  return;
572  }
573  p->x = p->x / d;
574  p->y = p->y / d;
575  p->z = p->z / d;
576  return;
577 }
double y
Definition: liblwgeom.h:324
double x
Definition: liblwgeom.h:324
#define FP_IS_ZERO(A)
double z
Definition: liblwgeom.h:324

Here is the caller graph for this function: