PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ normalize()

void normalize ( POINT3D p)

Normalize to a unit vector.

Definition at line 611 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_get_sortable_hash(), gbox_pt_outside(), lwpoly_pt_outside_hack(), point_in_cone(), ptarray_segmentize_sphere_edge_recursive(), sphere_angle(), test_sphere_project(), test_vector_angle(), unit_normal(), vector_angle(), and vector_rotate().

612 {
613  double d = sqrt(p->x*p->x + p->y*p->y + p->z*p->z);
614  if (FP_IS_ZERO(d))
615  {
616  p->x = p->y = p->z = 0.0;
617  return;
618  }
619  p->x = p->x / d;
620  p->y = p->y / d;
621  p->z = p->z / d;
622  return;
623 }
double y
Definition: liblwgeom.h:340
double x
Definition: liblwgeom.h:340
#define FP_IS_ZERO(A)
double z
Definition: liblwgeom.h:340
Here is the caller graph for this function: