GEOMETRY
Geometric Calculations
GEOMETRY,
a MATLAB library which
carries out geometric calculations in 2, 3 and N space.
These calculations include angles, areas, containment, distances,
intersections, lengths, and volumes.
Some geometric objects can be described in a variety of ways.
For instance, a line has implicit, explicit and parametric
representations. The names of routines often will specify
the representation used, and there are routines to convert
from one representation to another.
Another useful task is the delineation of a standard geometric
object. For instance, there is a routine that will return
the location of the vertices of an octahedron, and others to
produce a series of "equally spaced" points on a circle, ellipse,
sphere, or within the interior of a triangle.
Note that I much prefer vectors to be expressed as column vectors;
MATLAB, on the other hand, seems to make it easier to work with row
vectors. In my original codes, I primarily used row vectors, but
I have determined to convert to column vectors; the code is in the
middle of this transition, so in some cases there may be be some
inconsistencies in style, and accidental inconsistencies in use.
On the other hand, I am willing to put up with the practice of
declaring a column vector's entries as though they were in a matrix
of dimension n by 1, since this guarantees me that, for instance,
a dot product is written as (u' * v), and everything finally makes
sense to me.
Licensing:
The computer code and data files described and made available on this web page
are distributed under
the GNU LGPL license.
Languages:
GEOMETRY is available in
a C version and
a C++ version and
a FORTRAN90 version and
a MATLAB version and
a Python version.
Related Programs:
geometry_test
POLYGON_MOMENTS,
a MATLAB library which
computes arbitrary moments of a polygon.
SIMPLEX_COORDINATES,
a MATLAB library which
computes the Cartesian coordinates of the vertices of a regular
simplex in M dimensions.
SPHERE_GRID,
a MATLAB library which
provides a number of ways of generating grids of points, or of
points and lines, or of points and lines and faces, over the unit sphere.
SPHERE_STEREOGRAPH,
a MATLAB library which
computes the stereographic mapping between points on the unit sphere
and points on the plane Z = 1.
TETRAHEDRON_PROPERTIES,
a MATLAB program which
computes properties of a given tetrahedron.
TETRAHEDRONS,
a dataset directory which
contains examples of tetrahedrons;
TRIANGLES,
a dataset directory which
contains examples of triangles;
TRIANGULATE,
a MATLAB program which
triangulates a (possibly nonconvex)
polygon.
TRIANGULATION,
a MATLAB library which
defines and analyzes triangulations.
Reference:

Gerard Bashein, Paul Detmer,
Centroid of a Polygon,
in Graphics Gems IV,
edited by Paul Heckbert,
AP Professional, 1994,
ISBN: 0123361559,
LC: T385.G6974.

SF Bockman,
Generalizing the Formula for Areas of Polygons to Moments,
American Mathematical Society Monthly,
Volume 96, Number 2, February 1989, pages 131132.

Adrian Bowyer, John Woodwark,
A Programmer's Geometry,
Butterworths, 1983,
ISBN: 0408012420.

Paulo Cezar Pinto Carvalho, Paulo Roma Cavalcanti,
Point in Polyhedron Testing Using Spherical Polygons,
in Graphics Gems V,
edited by Alan Paeth,
Academic Press, 1995,
ISBN: 0125434553,
LC: T385.G6975.

Daniel Cohen,
Voxel Traversal along a 3D Line,
in Graphics Gems IV,
edited by Paul Heckbert,
AP Professional, 1994,
ISBN: 0123361559,
LC: T385.G6974.

Thomas Cormen, Charles Leiserson, Ronald Rivest,
Introduction to Algorithms,
MIT Press, 2001,
ISBN: 0262032937,
LC: QA76.C662.

Marc deBerg, Marc Krevald, Mark Overmars,
Otfried Schwarzkopf,
Computational Geometry,
Springer, 2000,
ISBN: 3540656200,
LC: QA448.D38.C65.

Jack Dongarra, Jim Bunch, Cleve Moler, Pete Stewart,
LINPACK User's Guide,
SIAM, 1979,
ISBN13: 9780898711721,
LC: QA214.L56.

James Foley, Andries vanDam, Steven Feiner, John Hughes,
Computer Graphics, Principles and Practice,
Second Edition,
Addison Wesley, 1995,
ISBN: 0201848406,
LC: T385.C5735.

Martin Gardner,
The Mathematical Carnival,
Knopf, 1975,
ISBN: 0394494067,
LC: QA95.G286.

Priamos Georgiades,
Signed Distance From Point To Plane,
in Graphics Gems III,
edited by David Kirk,
Academic Press, 1992,
ISBN: 0124096735,
LC: T385.G6973.

Branko Gruenbaum, Geoffrey Shephard,
Pick's Theorem,
The American Mathematical Monthly,
Volume 100, Number 2, February 1993, pages 150161.

John Harris, Horst Stocker,
Handbook of Mathematics and Computational Science,
Springer, 1998,
ISBN: 0387947469,
LC: QA40.S76.

Barry Joe,
GEOMPACK  a software package for the generation of meshes
using geometric algorithms,
Advances in Engineering Software,
Volume 13, 1991, pages 325331.

Anwei Liu, Barry Joe,
Quality Local Refinement of Tetrahedral Meshes Based
on 8Subtetrahedron Subdivision,
Mathematics of Computation,
Volume 65, Number 215, July 1996, pages 11831200.

Jack Kuipers,
Quaternions and Rotation Sequences,
Princeton, 1998,
ISBN: 0691102988,
LC: QA196.K85.

Robert Miller,
Computing the Area of a Spherical Polygon,
in Graphics Gems IV,
edited by Paul Heckbert,
Academic Press, 1994,
ISBN: 0123361559,
LC: T385.G6974.

Albert Nijenhuis, Herbert Wilf,
Combinatorial Algorithms for Computers and Calculators,
Second Edition,
Academic Press, 1978,
ISBN: 0125192606,
LC: QA164.N54.

Atsuyuki Okabe, Barry Boots, Kokichi Sugihara, Sung Nok Chiu,
Spatial Tesselations:
Concepts and Applications of Voronoi Diagrams,
Second Edition,
Wiley, 2000,
,
ISBN: 0471986356,
LC: QA278.2.O36.

Joseph ORourke,
Computational Geometry,
Second Edition,
Cambridge, 1998,
ISBN: 0521649765,
LC: QA448.D38.

Edward Saff, Arno Kuijlaars,
Distributing Many Points on a Sphere,
The Mathematical Intelligencer,
Volume 19, Number 1, 1997, pages 511.

Philip Schneider, David Eberly,
Geometric Tools for Computer Graphics,
Elsevier, 2002,
ISBN: 1558605940,
LC: T385.S334.

Peter Schorn, Frederick Fisher,
Testing the Convexity of a Polygon,
in Graphics Gems IV,
edited by Paul Heckbert,
AP Professional, 1994,
ISBN: 0123361559,
LC: T385.G6974.

Moshe Shimrat,
Algorithm 112:
Position of Point Relative to Polygon,
Communications of the ACM,
Volume 5, Number 8, August 1962, page 434.

Kenneth Stephenson,
Introduction to Circle Packing,
The Theory of Discrete Analytic Functions,
Cambridge, 2005,
ISBN: 0521823560,
LC: QA640.7S74.

Allen VanGelder,
Efficient Computation of Polygon Area and Polyhedron Volume,
in Graphics Gems V,
edited by Alan Paeth,
AP Professional, 1995,
ISBN: 0125434553,
LC: T385.G6975.

Daniel Zwillinger, Steven Kokoska,
Standard Probability and Statistical Tables,
CRC Press, 2000,
ISBN: 1584880597,
LC: QA273.3.Z95.
Source code:

angle_box_2d.m,
"boxes" an angle defined by three points in 2D;

angle_contains_point_2d.m,
determines if an angle contains a point in 2D;

angle_deg_2d.m,
returns the angle between two rays in 2D, in degrees;

angle_half_2d.m,
returns a ray defining half the angle between two rays in 2D;

angle_rad_2d.m,
returns the angle between two rays in 2D, in radians;

angle_rad_3d.m,
returns the angle between two rays in 3D, in radians;

angle_rad_nd.m,
returns the angle between two rays in ND, in radians;

angle_turn_2d.m,
returns the turning defined by an angle in 2D;

annulus_area_2d.m,
computes the area of a circular annulus;

annulus_sector_area_2d.m,
computes the area of an annulus sector;

annulus_sector_centroid_2d.m,
computes the centroid of an annulus sector;

ball01_sample_2d.m,
picks a random point in the unit ball in 2D;

ball01_sample_3d.m,
picks a random point in the unit ball in 3D;

ball01_sample_nd.m,
picks a random point in the unit ball in ND;

ball01_volume.m
returns the volume of the unit ball in 3D.

basis_map_3d.m,
computes the matrix which maps one basis to another in 3D;

box_contains_point_2d.m,
is TRUE if a point is contained in a box in 2D;

box_contains_point_nd.m,
is TRUE if a point is contained in a box in ND;

box_contains_segment_nd.m,
is TRUE if a line segment is contained in a box in ND;

box_ray_int_2d.m,
determines where a ray inside a box intersects the box boundary in 2D;

box_segment_clip_2d.m,
uses a box to clip a line in 2D;

box01_contains_point_2d.m,
is TRUE if a point is contained in a unit box in 2D;

box01_contains_point_nd.m,
is TRUE if a point is contained in a unit box in ND;

circle_arc_point_near_2d.m,
returns the nearest circle arc point to a point in 2D;

circle_area_2d.m,
returns the area of a circle in 2D;

circle_dia2imp_2d.m,
converts a diameter to an implicit circle in 2D;

circle_exp_contains_point_2d.m,
finds if an explicit circle contains a point in 2D;

circle_exp2imp_2d.m,
converts an explicit circle to an implicit circle in 2D;

circle_imp_contains_point_2d.m,
finds if an implicit circle contains a point in 2D;

circle_imp_line_par_int_2d.m,
finds intersections of an implicit circle and a parametric line in 2D;

circle_imp_point_dist_2d.m,
finds the distance from a point to an implicit circle in 2D;

circle_imp_point_dist_signed_2d.m,
finds the signed distance from a point to an implicit circle in 2D;

circle_imp_point_near_2d.m,
finds the nearest implicit circle point to a point in 2D;

circle_imp_points_2d.m,
returns points on an implicit circle in 2D;

circle_imp_points_3d.m,
returns points on an implicit circle in 3D;

circle_imp_points_arc_2d.m,
returns points on an implicit circular arc in 2D;

circle_imp_print_2d.m,
prints information about an implicit circle in 2D;

circle_imp_print_3d.m,
prints information about an implicit circle in 3D;

circle_imp2exp_2d.m,
converts an implicit circle to an explicit circle in 2D;

circle_llr2imp_2d.m,
converts a circle in LLR format to an implicit circle in 2D.

circle_lune_angle_by_height_2d.m,
computes the angle of a circular lune using the triangle height;

circle_lune_area_by_angle_2d.m,
computes the area of a circular lune using the subtended angle;

circle_lune_area_by_height_2d.m,
computes the area of a circular lune using the triangle height;

circle_lune_centroid_2d.m,
returns the centroid of a circular lune in 2D;

circle_lune_height_by_angle_2d.m,
computes the triangle height of a circular lune using the subtended angle;

circle_pppr2imp_3d
converts a circle from PPPR to implicit form in 3D.

circle_ppr2imp_2d.m,
converts a circle from PPR form into implicit form in 2D;

circle_sector_area_2d.m,
returns the area of a circle sector in 2D;

circle_sector_centroid_2d.m,
returns the centroid of a circle sector in 2D;

circle_sector_contains_point_2d.m,
reports if a circle sector contains a point in 2D.

circle_sector_print_2d.m,
prints information about a circle sector in 2D.

circle_triangle_area_2d.m,
returns the area of a circle triangle in 2D;

circles_intersect_area_2d.m,
finds the area of the intersection of two circles.

circles_intersect_points_2d.m,
finds intersection points of two circles;

cone_area_3d.m,
returns the surface area of a cone in 3D;

cone_centroid_3d.m,
returns the centroid of a cone in 3D;

cone_volume.m,
returns the volume of a cone in 3D;

conv3d.m,
uses a simple project to map 3D data to 2D;

cot_rad.m,
returns the cotangent of an angle given in radians;

cube_shape_3d.m,
returns shape information for a cube in 3D;

cube_size_3d.m,
returns "sizes" for a cube in 3D;

cylinder_point_dist_3d.m,
returns the distance from a point to a cylinder in 3D;

cylinder_point_dist_signed_3d.m,
returns the signed distance from a point to a cylinder in 3D;

cylinder_point_inside_3d.m,
reports whether a point is inside a cylinder in 3D;

cylinder_point_near_3d.m,
returns the nearest point on a cylinder in 3D;

cylinder_sample_3d.m,
returns sample points from a cylinder in 3D;

cylinder_volume_3d.m,
returns the volume of a cylinder in 3D;

degrees_to_radians.m,
converts an angle in degrees to one in radians;

dge_det.m,
computes the determinant of a DGE matrix;

dge_fa.m,
factors a DGE matrix;

dge_sl.m,
solves a linear system associated with a DGE matrix;

direction_pert_2d.m,
randomly perturbs a direction vector in 2D;

direction_uniform_2d.m,
generates a random direction vector in 2D;

direction_uniform_3d.m,
generates a random direction vector in 3D;

direction_uniform_nd.m,
generates a random direction vector in ND;

disk_point_dist_3d.m,
finds the distance from a point to a disk in 3D;

dms_to_radians.m,
converts from degrees/minutes/seconds to radians;

dodec_size_3d.m,
returns "sizes" for a dodecahedron in 3D;

dodec_shape_3d.m,
returns shape information for a dodecahedron in 3D;

dual_shape_3d.m,
returns information for the dual of a shape in 3D;

dual_size_3d.m,
returns "sizes" for the dual of a shape in 3D;

ellipse_area1.m,
returns the area of an ellipse x'*A*x=r^2;

ellipse_area2.m,
returns the area of an ellipse ax^2+bxy+cy^2=d;

ellipse_area3.m,
returns the area of an ellipse (x/r1)^2+(y/r2)^2=1;

ellipse_point_dist_2d.m,
returns the distance to an ellipse in 2D;

ellipse_point_near_2d.m,
returns the nearest point on an ellipse in 2D;

ellipse_points_2d.m,
returns points on an ellipse in 2D;

ellipse_points_arc_2d.m,
returns points on an elliptical arc;

glob2loc_3d.m,
converts from a global to local coordinate system in 3D;

halfplane_contains_point_2d.m,
reports if a halfplane contains a point in 2D;

halfspace_imp_triangle_int_3d.m,
finds the intersection of an implicit halfspace with a triangle in 3D;

halfspace_normal_triangle_int_3d.m,
finds the intersection of a normal halfspace with a triangle in 3D;

halfspace_triangle_int_3d.m,
finds the intersection of a halfspace with a triangle in 3D;

helix_shape_3d.m,
computes point on a helix in 3D;

hexagon_area_2d.m,
returns the area of a hexagon in 2D;

hexagon_contains_point_2d.m,
reports whether a hexagon contains a point;

hexagon01_area_2d.m,
returns the area of a unit hexagon in 2D;

hexagon01_shape_2d.m,
returns a point on the unit hexagon in 2D, specified by angle;

hexagon01_vertices_2d.m,
returns the vertices of a unit hexagon in 2D;

hyperball01_volume.m,
returns the volume of the unit hyperball.

i4_dedekind_factor.m,
computes a function needed for a Dedekind sum;

i4_dedekind_sum.m,
computes the Dedekind sum of two I4's.

i4_factorial2.m,
evaluates the double factorial function;

i4_gcd.m,
returns the greatest common divisor of two I4's;

i4_lcm.m,
returns the lowest common multiple of two I4's;

i4_modp.m,
returns the nonnegative remainder of integer division;

i4_swap.m,
swaps two integer values;

i4_uniform_ab.m,
returns a random I4 in [A,B]e;

i4_wrap.m,
forces an integer to lie in a given range;

i4col_compare.m,
compares two columns of an I4COL;

i4col_find_item.m,
searches for a given value in an I4COL;

i4col_find_pair_wrap.m,
wrapsearches a table by columns for a pair of values;

i4col_sort_a.m,
ascending sorts the columns of an I4COL;

i4col_sorted_unique_count.m,
counts the unique columns in a sorted I4COL;

i4col_swap.m,
swaps two columns of an I4COL;

i4mat_print.m,
prints an integer matrix;

i4mat_print_some.m,
prints some of an integer matrix;

i4mat_transpose_print.m,
prints an integer matrix, transposed;

i4mat_transpose_print_some.m,
prints some of an integer matrix, transposed;

i4row_compare.m,
compares two rows of an integer array;

i4row_sort_a.m,
ascending sorts the rows of an integer array;

i4row_swap.m,
swaps two rows of an integer array;

i4vec_heap_d.m,
reorders an I4VEC into a descending heap;

i4vec_indicator1.m,
sets an I4VEC to the indicator1 vector;

i4vec_lcm.m,
returns the least common multiple of an I4VEC;

i4vec_print.m,
prints an I4VEC;

i4vec_print_some.m,
prints some of an I4VEC;

i4vec_sort_heap_a.m,
ascending sorts an I4VEC using heap sort;

i4vec_sorted_unique.m,
returns the unique elements in a sorted I4VEC;

i4vec_uniform_ab.m,
returns a random I4VEC;

i4vec2_compare.m,
compares pairs of integers stored in two vectors;

i4vec2_sort_a.m,
ascending sorts a pair of I4VEC's;

i4vec2_sorted_unique.m,
finds unique elements in a sorted IVEC2.

icos_size.m,
gives "sizes" for an icosahedron;

icos_shape.m,
describes an icosahedron;

line_exp_is_degenerate_nd.m,
determines if an explicit line is degenerate in ND;

line_exp_normal_2d.m,
computes the unit normal to an explicit line in 2D;

line_exp_perp_2d.m,
returns a line perpendicular to an explicit line in 2D;

line_exp_point_dist_2d.m,
returns the distance from a point to an explicit line in 2D;

line_exp_point_dist_3d.m,
returns the distance from a point to an explicit line in 3D;

line_exp_point_dist_signed_2d.m,
returns the signed distance from a point to an explicit line in 2D;

line_exp_point_near_2d.m,
returns the nearest point on an explicit line in 2D;

line_exp_point_near_3d.m,
returns the nearest point on an explicit line in 3D;

line_exp2imp_2d.m,
converts an explicit line to an implicit line in 2D;

line_exp2par_2d.m,
converts an explicit line to a parametric line in 2D;

line_exp2par_3d.m,
converts an explicit line to a parametric line in 3D;

line_imp_is_degenerate_2d.m,
determines if an implicit line is degenerate in 2D;

line_imp_point_dist_2d.m,
returns the distance from a point to an implicit line in 2D;

line_imp_point_dist_signed_2d.m,
returns the signed distance from a point to an implicit line in 2D;

line_imp2exp_2d.m,
converts an implicit to explicit line in 2D;

line_imp2par_2d.m,
converts an implicit to parametric line in 2D;

line_par_point_dist_2d.m,
returns the distance from a point to a parametric line in 2D;

line_par_point_dist_3d.m,
returns the distance from a point to a parametric line in 3D;

line_par_point_near_2d.m,
returns the nearest point on a parametric line to a point in 2D;

line_par_point_near_3d.m,
returns the nearest point on a parametric line to a point in 3D;

line_par2exp_2d.m,
converts a parametric to explicit line in 2D;

line_par2exp_3d.m,
converts a parametric to explicit line in 3D;

line_par2imp_2d.m,
converts a parametric to implicit line in 2D;

lines_exp_angle_3d.m,
finds the angle between explicit lines in 3D;

lines_exp_angle_nd.m,
finds the angle between explicit lines in ND;

lines_exp_dist_3d.m,
finds the distance between explicit lines in 3D;

lines_exp_dist_3d_2.m,
finds the distance between explicit lines in 3D;

lines_exp_equal_2d.m,
determines if two explicit lines are equal in 2D.

lines_exp_int_2d.m,
finds the intersection of two explicit lines in 2D;

lines_exp_near_3d.m,
finds the nearest points on two explicit lines in 3D;

lines_exp_parallel_2d.m,
finds if two explicit lines in 2D are parallel;

lines_exp_parallel_3d.m,
finds if two explicit lines in 3D are parallel;

lines_imp_angle_2d.m,
finds the angle between two implicit lines in 2D;

lines_imp_dist_2d.m,
finds the distance between two implicit lines in 2D;

lines_imp_int_2d.m,
finds the intersection of two implicit lines in 2D;

lines_par_angle_2d.m,
finds the angle between parametric lines in 2D;

lines_par_angle_3d.m,
finds the angle between parametric lines in 3D;

lines_par_dist_3d.m,
finds the distance between parametric lines in 3D;

lines_par_int_2d.m,
finds the intersection of two parametric lines in 2D;

loc2glob_3d.m,
converts from a local to global coordinate system in 3D;

minabs.m,
minimizes Y = A * X + B in an interval;

minquad.m,
minimizes Y = A * X * X + B * X + C in an interval;

normal_01_sample.m,
samples the standard normal probability density function;

octahedron_shape_3d.m,
returns shape information for an octahedron in 3D;

octahedron_size_3d.m,
returns size information for an octahedron in 3D;

parabola_ex.m,
finds the extremal point of a parabola determined by three values;

parabola_ex2.m,
finds the extremal point of a parabola determined by three values;

parallelogram_area_2d.m,
computes the area of a parallelogram in 2D;

parallelogram_area_3d.m,
computes the area of a parallelogram in 3D;

parallelogram_contains_point_2d.m,
checks whether a point is contained in a parallelogram in 2D;

parallelogram_contains_point_3d.m,
checks whether a point is contained in a parallelogram in 3D;

parallelogram_point_dist_3d.m,
finds the distance to a parallelogram in 3D;

parallelepiped_contains_point_3d.m,
reports if a point is inside a parallelepiped in 3D;

parallelepiped_point_dist_3d.m,
finds the distance to a parallelepiped in 3D;

perm_check.m,
checks a permutation;

perm_inv.m,
computes the inverse of a permutation;

plane_exp_grid_3d.m,
computes points and lines making a grid on an explicit plane in 3D;

plane_exp_normal_3d.m,
finds the normal to an explicit plane in 3D;

plane_exp_point_dist_3d.m,
finds the distance between a point and an explicit plane in 3D;

plane_exp_pro2.m,
produces the inplane coordinates of points on an explicit plane in 3D;

plane_exp_pro3.m,
projects points orthographically onto an explicit plane in 3D;

plane_exp_project_3d.m,
projects points through a point and onto an explicit plane in 3D;

plane_exp2imp_3d.m,
converts a plane from explicit to implicit form in 3D;

plane_exp2normal_3d.m,
converts a plane from explicit to normal form in 3D;

plane_imp_is_degenerate_3d.m,
is true if an implicit plane in 3D is degenerate;

plane_imp_line_par_int_3d.m,
determines if an implicit plane and a parametric line intersect in 3D;

plane_imp_point_dist_3d.m,
determines the distance to an implicit plane in 3D;

plane_imp_point_dist_signed_3d.m,
determines the signed distance to an implicit plane in 3D;

plane_imp_point_near_3d.m,
determines the nearest point on an implicit plane in 3D;

plane_imp_segment_near_3d.m,
finds the nearest points on an implicit plane and a line segment in 3D;

plane_imp_triangle_int_3d.m,
finds intersections of an implicit plane and a triangle in 3D;

plane_imp_triangle_int_add_3d.m,
a utility for triangle/plane intersections in 3D;

plane_imp_triangle_near_3d.m,
finds nearest points on an implicit plane and a triangle in 3D;

plane_imp2exp_3d.m,
converts a plane from implicit to explicit form in 3D;

plane_imp2normal_3d.m,
converts a plane from implicit to normal form in 3D;

plane_normal_basis_3d.m,
finds two perpendicular vectors in a plane in normal form in 3D;

plane_normal_line_exp_3d.m,
determines where an explicit line intersects a plane in
normal form in 3D;

plane_normal_qr_to_xyz.m,
converts from QR to XYZ coordinates in a normal plane;

plane_normal_tetrahedron_intersect.m,
finds intersections of a normal plane and a tetrahedron;

plane_normal_triangle_int_3d.m,
finds intersections of a normal plane and a triangle in 3D;

plane_normal_uniform_3d.m,
chooses a normal plane at random in 3D;

plane_normal_uniform_nd.m,
chooses a normal plane at random in ND;

plane_normal_xyz_to_qr.m,
converts from XYZ_TO_QR coordinates in a normal plane;

plane_normal2exp_3d.m,
converts a plane from normal to explicit form in 3D;

plane_normal2imp_3d.m,
converts a plane from normal to implicit form in 3D;

planes_imp_angle_3d.m,
finds the dihedral angle between implicit planes in 3D;

points_avoid_point_naive_2d.m,
is a point "far enough" from a set of points in 2D?;

points_bisect_line_imp_2d.m,
implicit bisector line between two points in 2D;

points_bisect_line_par_2d.m,
parametric bisector line between two points in 2D;

points_centroid_2d.m,
computes the discrete centroid of a point set in 2D;

points_colin_2d.m,
estimates the colinearity of 3 points in 2D;

points_colin_3d.m,
estimates the colinearity of 3 points in 3D;

points_dist_nd.m,
returns the distance between two points in ND;

points_hull_2d.m,
computes the convex hull of a set of points in 2D;

points_plot.m,
makes an EPS plot of a set of points;

points_point_near_naive_nd.m,
finds the nearest of a set of points to a point in ND;

polar_to_xy.m,
converts polar coordinates to XY coordinates;

polygon_1_2d.m,
integrates the function 1 over a polygon in 2D;

polygon_angles_2d.m,
computes the angles of a polygon in 2D;

polygon_area_2d.m,
computes the area of a polygon in 2D;

polygon_area_2d_2.m,
computes the area of a polygon in 2D;

polygon_area_3d.m,
computes the area of a polygon in 3D;

polygon_area_3d_2.m,
computes the area of a polygon in 3D;

polygon_centroid_2d.m,
computes the centroid of a polygon in 2D;

polygon_centroid_2d_2.m,
computes the centroid of a polygon in 2D;

polygon_centroid_3d.m,
computes the centroid of a polygon in 3D;

polygon_contains_point_2d.m,
finds if a point is inside a simple polygon in 2D;

polygon_contains_point_2d_2.m,
finds if a point is inside a simple polygon in 2D;

polygon_diameter_2d.m,
computes the diameter of a polygon in 2D;

polygon_expand_2d.m,
"expands" a polygon in 2D;

polygon_inrad_data_2d.m,
uses the inradius to compute other data for a regular polygon in 2D;

polygon_is_convex_2d.m,
determines the convexity of a polygon in 2D;

polygon_lattice_area_2d.m,
finds the area of a lattice polygon in 2D;

polygon_normal_3d.m,
finds the normal vector for a (planar) polygon in 3D;

polygon_outrad_data_2d.m,
uses the outradius to compute other data for a regular polygon in 2D;

polygon_point_dist_2d.m,
finds the distance to a polygon in 2D;

polygon_point_near_2d.m,
finds the nearest point on a polygon in 2D;

polygon_side_data_2d.m,
uses the side length to compute other data for a regular polygon
in 2D;

polygon_solid_angle_3d.m,
determines the solid angle subtended by a polygon with respect
to a unit sphere around a given point in 3D;

polygon_x_2d.m,
integrates the function x over a polygon in 2D;

polygon_xx_2d.m,
integrates the function x^2 over a polygon in 2D;

polygon_xy_2d.m,
integrates the function x*y over a polygon in 2D;

polygon_y_2d.m,
integrates the function y over a polygon in 2D;

polygon_yy_2d.m,
integrates the function y*y over a polygon in 2D;

polyhedron_area_3d.m,
computes the surface area of a polyhedron in 3D;

polyhedron_centroid_3d.m,
computes the centroid of a polyhedron in 3D;

polyhedron_contains_point_3d.m,
determines if a point is inside a polyhedron in 3D;

polyhedron_volume_3d.m,
computes the volume of a polyhedron in 3D;

polyhedron_volume_3d_2.m,
computes the volume of a polyhedron in 3D;

polyline_arclength_nd.m,
returns the arclength of points on a polyline in ND;

polyline_index_point_nd.m,
returns the point with given arclength on a polyline in ND;

polyline_length_nd.m,
returns the length of a polyline in ND;

polyline_points_nd.m,
returns equally spaced points on a polyline in ND;

polyloop_arclength_nd.m,
returns the arclength of points on a polyloop in ND;

polyloop_length_nd.m,
returns the length of a polyloop in ND;

polyloop_points_nd.m,
returns equally spaced points on a polyloop in ND;

provec.m,
projects a vector from an M dimensional space to an N dimensional space;

pyramid_volume_3d.m,
returns the volume of a pyramid in 3D;

pyramid01_volume_3d.m,
returns the volume of the unit pyramid in 3D;

quad_angles.m,
returns the angles of a quadrilateral;

quad_angles_degrees.m,
returns the angles of a quadrilateral in degrees;

quad_area_2d.m,
returns the area of a quadrilateral in 2D;

quad_area2_2d.m,
returns the area of a quadrilateral in 2D;

quad_area_3d.m,
returns the area of a quadrilateral in 3D;

quad_contains_point_2d.m,
finds if a point is inside a convex quadrilateral in 2D;

quad_convex_random.m,
returns a random convex quadrilateral in the unit square.

quad_is_convex.m,
returns TRUE if a quadrilateral is convex.

quad_is_simple.m,
is TRUE is a quadrilateral is "simple", that is, nondegenerate;

quad_perimeter.m,
computes the length of the perimeter of a quadrilateral;

quad_point_dist_2d.m,
finds the distance from a point to a quadrilateral in 2D;

quad_point_dist_signed_2d.m,
finds the signed distance from a point to a quadrilateral in 2D;

quad_point_near_2d.m,
finds the nearest point on a quadrilateral in 2D;

quad_random.m,
returns a random quadrilateral;

quad_simple_random.m,
returns a random simple quadrilateral;

r8_acos.m,
computes the inverse cosine;

r8_asin.m,
computes the inverse sine;

r8_atan.m,
computes the inverse tangent of Y / X;

r8_cosd.m,
returns the cosine of an angle given in degrees;

r8_cotd.m,
returns the cotangent of an angle given in degrees;

r8_cscd.m,
returns the cosecant of an angle given in degrees;

r8_haversine.m,
returns the haversine of an angle;

r8_huge.m,
returns a "huge" R8;

r8_modp.m,
returns the positive remainder of R8 division;

r8_normal_01.m,
returns a unit normally distributed R8;

r8_secd.m,
returns the secant of an angle given in degrees;

r8_sign.m,
returns the sign of an R8;

r8_sign_opposite_strict.m,
is TRUE if two R8's have strictly opposite signs.

r8_sind.m,
returns the sine of an angle given in degrees;

r8_swap.m,
swaps two R8's;

r8_tand.m,
returns the tangent of an angle given in degrees;

r8_uniform_01.m,
returns a unit pseudorandom R8;

r8_uniform_ab.m,
returns a pseudorandom R8 in [A,B];

r82vec_part_quick_a.m,
ascending partitions an R82VEC as part of a quicksort;

r82vec_permute.m,
permutes an R82VEC in place;

r82vec_print.m,
prints an R82VEC;

r82vec_sort_heap_index_a.m,
does an indexed heap ascending sort of an R82VEC;

r82vec_sort_quick_a.m,
ascending quicksorts an R82VEC;

r8mat_det_2d.m,
computes the determinant of a 2 by 2 matrix;

r8mat_det_3d.m,
computes the determinant of a 3 by 3 matrix;

r8mat_det_4d.m,
computes the determinant of a 4 by 4 matrix;

r8mat_det_5d.m,
computes the determinant of a 5 by 5 matrix;

r8mat_inverse_2d.m,
computes the inverse of a 2 by 2 matrix;

r8mat_inverse_3d.m,
computes the inverse of a 3 by 3 matrix;

r8mat_print.m,
prints an R8MAT;

r8mat_print_some.m,
prints some of an R8MAT;

r8mat_solve_2d.m,
solves a 2 by 2 system using Cramer's rule.

r8mat_transpose_print.m,
prints the transpose of an R8MAT;

r8mat_transpose_print_some.m,
prints some of the transpose of an R8MAT;

r8mat_uniform_01.m,
returns a unit pseudorandom R8MAT.

r8mat_uniform_ab.m,
returns a scaled pseudorandom R8MAT.

r8vec_angle_3d.m,
computes the angle between two vectors in 3D;

r8vec_any_normal.m,
returns a unit normal vector to a given vector;

r8vec_bracket.m,
searches a sorted R8VEC for brackets of a value;

r8vec_cross_product_2d.m,
computes the cross product of two R8VEC's in 2D;

r8vec_cross_product_affine_2d.m,
computes the affine cross product of two R8VEC's in 2D;

r8vec_cross_product_3d.m,
computes the cross product of two R8VEC's in 3D;

r8vec_cross_product_affine_3d.m,
computes the affine cross product of two R8VEC's in 3D;

r8vec_distance.m,
returns the distance between two R8VEC's;

r8vec_dot_product.m,
computes the dot product of two R8VEC's;

r8vec_dot_product_affine.m,
computes the affine dot product of two R8VEC's;

r8vec_eq.m,
is true if two R8VEC's are equal;

r8vec_gt.m,
is true if one R8VEC is greater than another;

r8vec_lt.m,
is true if one R8VEC is less than another;

r8vec_norm.m,
returns the L2 norm of an R8VEC;

r8vec_norm_affine.m,
returns the affine L2 norm of an R8VEC.

r8vec_normal_01.m,
returns a unit pseudonormal R8VEC;

r8vec_normsq.m,
returns the squared L2 norm of an R8VEC.

r8vec_normsq_affine.m,
returns the squared affine L2 norm of an R8VEC.

r8vec_print.m,
prints an R8VEC;

r8vec_scalar_triple_product.m,
computes the scalar triple product;

r8vec_swap.m,
swaps two R8VEC's;

r8vec_uniform_01.m,
returns a unit pseudorandom R8VEC.

r8vec_uniform_ab.m,
returns a scaled pseudorandom R8VEC.

r8vec_uniform_unit.m,
returns a random unit vector.

r8vec3_print.m,
prints three R8VEC's together;

radec_distance_3d.m,
angular distance, astronomical units, sphere in 3D;

radec_to_xyz.m,
converts right ascension/declination to XYZ coordinates;

radians_to_degrees.m,
converts an angle in radians to one in degrees;

radians_to_dms.m,
converts an angle in radians to one in degrees/minutes/seconds;

rotation_axis_vector_3d.m,
rotates a vector about an axis vector in 3D;

rtp_to_xyz.m,
converts (R,Theta,Phi) coordinates to XYZ coordinates;

segment_contains_point_1d.m,
determines if a point is contained in a line segment in 1D;

segment_contains_point_2d.m,
determines if a point is contained in a line segment in 2D;

segment_point_coords_2d.m,
computes the "coordinates" of a point relative to a line
segment in 2D;

segment_point_coords_3d.m,
computes the "coordinates" of a point relative to a line
segment in 3D;

segment_point_dist_2d.m,
computes the distance between a point and a line segment in 2D;

segment_point_dist_3d.m,
computes the distance between a point and a line segment in 3D;

segment_point_near_2d.m,
returns the nearest line segment point to a point in 2D;

segment_point_near_3d.m,
returns the nearest line segment point to a point in 3D;

segments_curvature_2d.m,
returns the curvature between two line segments in 2D;

segments_dist_2d.m,
returns the distance between two line segments in 2D;

segments_dist_3d.m,
returns the distance between two line segments in 3D;

segments_int_1d.m,
returns the intersection of two line segments in 1D;

segments_int_2d.m,
returns the intersection of two line segments in 2D;

shape_point_dist_2d.m,
computes the distance between a regular shape and a point in 2D;

shape_point_near_2d.m,
computes the nearest point on a regular shape in 2D;

shape_print_3d.m,
prints information about a shape in 3D;

shape_ray_int_2d.m,
finds the intersection of a regular shape and an internal ray in 2D;

simplex_lattice_layer_point_next.m,
returns the next simplex lattice layer point;

simplex_lattice_point_next.m,
returns the next simplex lattice point;

simplex_volume_nd.m,
returns the volume of a simplex in ND;

simplex01_lattice_point_num_nd.m,
counts lattice points in the unit simplex in ND;

simplex01_volume_nd.m,
returns the volume of the unit simplex in ND;

sin_power_int.m,
evaluates the sine power integral;

soccer_shape_3d.m,
gives information for a soccer ball (truncated icosahedron) in 3D;

soccer_size_3d.m,
gives "sizes" for a soccer ball (truncated icosahedron) in 3D;

sort_heap_external.m,
externally sorts a list of values into ascending order;

sphere_cap_area_2d.m,
computes the area of a sphere cap in 2D;

sphere_cap_area_3d.m,
computes the area of a sphere cap in 3D;

sphere_cap_area_nd.m,
computes the area of a sphere cap in ND;

sphere_cap_volume_2d.m,
computes the volume of a sphere cap in 2D;

sphere_cap_volume_3d.m,
computes the volume of a sphere cap in 3D;

sphere_cap_volume_nd.m,
computes the volume of a sphere cap in ND;

sphere_dia2imp_3d.m,
converts a diameter to an implicit sphere in 3D;

sphere_distance_xyz.m,
computes great circle distances on a sphere.

sphere_distance1.m,
computes the distance between two points on a sphere;

sphere_distance2.m,
computes the distance between two points on a sphere;

sphere_distance3.m,
computes the distance between two points on a sphere;

sphere_exp_contains_point_3d.m,
reports if a point is inside an explicit sphere in 3D;

sphere_exp_point_near_3d.m,
finds the nearest point on an explicit sphere in 3D;

sphere_exp2imp_3d.m,
converts an explicit to implicit sphere in 3D;

sphere_exp2imp_nd.m,
converts an explicit to implicit sphere in ND,
that is, it finds an Ndimensional sphere through N+1 points.

sphere_imp_area_3d.m,
computes the area of an implicit sphere in 3D;

sphere_imp_area_nd.m,
computes the area of an implicit sphere in ND;

sphere_imp_contains_point_3d.m,
determines if a point is inside an implicit sphere in 3D;

sphere_imp_gridfaces_3d.m,
produces a grid of triangles on an implicit sphere in 3D;

sphere_imp_line_project_3d.m,
projects a line onto an implicit sphere in 3D;

sphere_imp_local2xyz_3d.m,
converts local to XYZ coordinates on an implicit sphere in 3D;

sphere_imp_point_near_3d.m,
given a point, finds the nearest point on an implicit sphere in 3D;

sphere_imp_point_project_3d.m,
projects a point onto an implicit sphere in 3D;

sphere_imp_volume_3d.m,
computes the volume of an implicit sphere in 3D;

sphere_imp_volume_nd.m,
computes the volume of an implicit sphere in ND;

sphere_imp_zone_area_3d.m,
computes the area of zone of an implicit sphere in 3D;

sphere_imp_zone_volume_3d.m,
computes the volume of zone of an implicit sphere in 3D;

sphere_imp2exp_3d.m,
converts an implicit to explicit sphere in 3D;

sphere_k.m,
computes a factor useful for certain spherical calculations;

sphere_polygon_area_3d.m,
computes the area of a spherical polygon;

sphere01_area_nd.m,
returns the area of a unit sphere in ND;

sphere01_area_values.m,
returns some areas of a unit sphere in ND;

sphere01_sample_2d.m,
returns a random point in a sphere in 2D;

sphere01_sample_3d.m,
returns a random point in a sphere in 3D;

sphere01_sample_3d_2.m,
a BAD method for returning a random point in a sphere in 3D;

sphere01_sample_nd.m,
returns a random point in a sphere in ND;

sphere01_sample2_nd.m,
returns a random point in a sphere in ND;

sphere01_sample3_nd.m,
returns a random point in a sphere in ND;

sphere01_volume_nd.m,
computes the volume of a unit sphere in ND;

sphere01_volume_values.m,
returns some volumes of a unit sphere in ND;

sphere01_distance_xyz.m,
computes great circle distances on a unit sphere.

sphere_triangle_angles_to_area.m,
computes the area of a spherical triangle;

sphere_triangle_sides_to_angles.m,
computes the angles of a spherical triangle from its sides;

sphere_triangle_vertices_to_angles.m,
computes the angles of a spherical triangle from its vertices;

sphere_triangle_vertices_to_area.m,
computes the area of a spherical triangle from its vertices;

sphere_triangle_vertices_to_centroid.m,
computes the centroid of a spherical triangle from its vertices;

sphere_triangle_vertices_to_orientation.m,
attempts to define an orientation for a spherical triangle from its vertices;

sphere_triangle_vertices_to_sides.m,
computes the sides of a spherical triangle from its sides;

sphere01_triangle_angles_to_area.m,
computes the area of a spherical triangle on a unit sphere.

sphere01_triangle_sides_to_angles.m,
computes the angles of a spherical triangle from its sides
on a unit sphere.

sphere01_triangle_vertices_to_angles.m,
computes the angles of a spherical triangle from its vertices
on a unit sphere.

sphere01_triangle_vertices_to_area.m,
computes the area of a spherical triangle from its vertices
on a unit sphere.

sphere01_triangle_vertices_to_centroid.m,
computes the centroid of a spherical triangle from its vertices
on a unit sphere.

sphere01_triangle_vertices_to_sides.m,
computes the sides of a spherical triangle from its sides
on a unit sphere.

string_2d.m,
groups line segments into connected lines in 2D;

super_ellipse_points_2d.m,
returns points on a superellipse in 2D;

tetrahedron_barycentric_3d.m,
returns the barycentric coordinates of a point in 3D;

tetrahedron_centroid_3d.m,
returns the centroid of a tetrahedron in 3D;

tetrahedron_circumsphere_3d.m,
returns the circumsphere of a tetrahedron in 3D;

tetrahedron_contains_point_3d.m,
is TRUE if a tetrahedron contains a point in 3D;

tetrahedron_dihedral_angles_3d.m,
returns the 6 dihedral angles of a tetrahedron in 3D;

tetrahedron_edge_length_3d.m,
returns the edge lengths of a tetrahedron in 3D;

tetrahedron_face_angles_3d.m,
returns the 12 face angles of a tetrahedron in 3D;

tetrahedron_face_areas_3d.m,
returns the 4 face areas of a tetrahedron in 3D;

tetrahedron_insphere_3d.m,
returns the insphere of a tetrahedron in 3D;

tetrahedron_lattice_layer_point_next.m,
next tetrahedron lattice layer point;

tetrahedron_lattice_point_next.m,
returns the next tetrahedron lattice point;

tetrahedron_quality1_3d.m,
returns the quality of a tetrahedron in 3D;

tetrahedron_quality2_3d.m,
returns the quality of a tetrahedron in 3D;

tetrahedron_quality3_3d.m,
returns the quality of a tetrahedron in 3D;

tetrahedron_quality4_3d.m,
returns the quality of a tetrahedron in 3D;

tetrahedron_rhombic_shape_3d.m,
describes the shape of a rhombic tetrahedron in 3D;

tetrahedron_rhombic_size_3d.m,
gives "sizes" for a rhombic tetrahedron in 3D;

tetrahedron_sample_3d.m,
returns a random point from a tetrahedron in 3D;

tetrahedron_shape_3d.m,
describes the shape of a tetrahedron in 3D;

tetrahedron_size_3d.m,
gives "sizes" for a tetrahedron in 3D;

tetrahedron_solid_angles_3d.m,
returns the 4 solid angles of a tetrahedron in 3D;

tetrahedron_volume_3d.m,
computes the volume of a tetrahedron in 3D;

tetrahedron01_lattice_point_num_3d.m,
counts lattice points;

tetrahedron01_volume.m
returns the volume of the unit tetrahedron in 3D.

timestamp.m,
prints the current YMDHMS date as a timestamp;

tmat_init.m,
initializes a transformation matrix to the identity;

tmat_mxm.m,
multiplies two transformation matrices;

tmat_mxp.m,
multiplies a transformation matrix times a physical point;

tmat_mxp2.m,
multiplies a transformation matrix times a number of physical points;

tmat_mxv.m,
multiplies a transformation matrix times a vector;

tmat_rot_axis.m,
applies a coordinate axis rotatition to a transformation matrix;

tmat_rot_vector.m,
applies an arbitrary rotation to a transformation matrix;

tmat_scale.m,
applies a scaling to a transformation matrix;

tmat_shear.m,
applies a shear to a transformation matrix;

tmat_trans.m,
applies a translation to a transformation matrix;

torus_area_3d.m,
returns the area of a torus in 3D;

torus_volume_3d.m,
returns the volume of a torus in 3D;

tp_to_xyz.m,
converts unit spherical coordinates to XYZ coordinates;

triangle_angles_2d.m,
returns the angles of a triangle in 2D;

triangle_angles_3d.m,
returns the angles of a triangle in 3D;

triangle_area_2d.m,
returns the area of a triangle in 2D;

triangle_area_3d.m,
returns the area of a triangle in 3D;

triangle_area_3d_2.m,
returns the area of a triangle in 3D;

triangle_area_3d_3.m,
returns the area of a triangle in 3D;

triangle_area_heron.m,
returns the area of a triangle in any dimension;

triangle_area_vector_3d.m,
returns the area vector of a triangle in 3D;

triangle_barycentric_2d.m,
returns the barycentric coordinates of a point in a triangle in 2D;

triangle_centroid_2d.m,
returns the centroid of a triangle in 2D;

triangle_centroid_3d.m,
returns the centroid of a triangle in 3D;

triangle_circumcenter_2d.m,
returns the circumcenter of a triangle in 2D;

triangle_circumcenter_2d_2.m,
returns the circumcenter of a triangle in 2D;

triangle_circumcenter.m,
returns the circumcenter of a triangle in ND;

triangle_circumcircle_2d.m,
returns the circumcenter of a triangle in 2D;

triangle_circumcircle_2d_2.m,
returns the circumcenter of a triangle in 2D;

triangle_circumradius_2d.m,
returns the circumradius of a triangle in 2D;

triangle_contains_line_exp_3d.m,
determines if an explicit line passes through a triangle in 3D;

triangle_contains_line_par_3d.m,
determines if a parametric line passes through a triangle in 3D;

triangle_contains_point_2d_1.m,
determines if a point is in a triangle in 2D;

triangle_contains_point_2d_2.m,
determines if a point is in a triangle in 2D;

triangle_contains_point_2d_3.m,
determines if a point is in a triangle in 2D;

triangle_edge_length_2d.m,
returns the edge lengths of a triangle in 2D;

triangle_gridpoints_2d.m,
computes gridpoints within a triangle in 2D;

triangle_incenter_2d.m,
returns the incenter of a triangle in 2D;

triangle_incircle_2d.m,
returns the incircle of a triangle in 2D;

triangle_inradius_2d.m,
returns the inradius of a triangle in 2D;

triangle_is_degenerate_nd.m,
determines if a triangle is degenerate in ND;

triangle_lattice_layer_point_next.m,
next triangle lattice layer point;

triangle_lattice_point_next.m,
returns the next triangle lattice point;

triangle_line_imp_int_2d.m,
finds intersections of an implicit line with a triangle in 2D;

triangle_orientation_2d.m,
returns the orientation of a triangle in 2D;

triangle_orthocenter_2d.m,
returns the orthocenter of a triangle in 2D;

triangle_point_dist_2d.m,
returns the distance of point to a triangle in 2D;

triangle_point_dist_3d.m,
returns the distance of point to a triangle in 3D;

triangle_point_dist_signed_2d.m,
returns the signed distance of point to a triangle in 2D;

triangle_point_near_2d.m,
returns the nearest point on a triangle in 2D;

triangle_quality_2d.m,
returns the shape quality of a triangle in 2D;

triangle_right_lattice_point_num_2d.m,
counts lattice points;

triangle_sample.m,
randomly samples a point from a triangle in 2D;

triangle_unit_lattice_point_num_2d.m,
counts lattice points;

triangle_xsi_to_xy_2d.m,
converts barycentric to cartesian coordinates in a triangle in 2D;

triangle_xy_to_xsi_2d.m,
converts cartesian to barycentric coordinates in a triangle in 2D;

truncated_octahedron_shape_3d.m,
returns shape information for a truncated octahedron in 3D;

truncated_octahedron_size_3d.m,
gives "sizes" for a truncated octahedron in 3D;

tube_2d.m,
constructs a "tube" of given width around a path in 2D;

tuple_next2.m,
returns the next element of an integer tuple sequence;

tuple_next2_test.m

vector_directions_nd.m,
returns the direction angles of a vector in ND;

vector_rotate_2d.m,
rotates a vector in 2D;

vector_rotate_3d.m,
rotates a vector in 3D;

vector_rotate_base_2d.m,
rotates a vector around a base point in 2D;

vector_separation_nd.m,
finds the angular separation between two vectors in ND;

vector_unit_nd.m,
normalizes a vector in ND;

voxels_dist_l1_nd.m,
finds the L1 distance between voxels in ND;

voxels_line_3d.m,
produces voxels along a line in 3D;

voxels_region_3d.m,
arranges contiguous voxels into regions in 3D;

voxels_step_3d.m,
produces voxels along a line from a given point in 3D;

wedge01_volume.m
returns the volume of the unit wedge in 3D.

xy_to_polar.m,
converts XY coordinates to polar coordinates;

xyz_to_radec.m,
converts XYZ coordinates to right ascension and declension;

xyz_to_rtp.m,
converts XYZ coordinates to (R,Theta,Phi) coordinates;

xyz_to_tp.m,
converts XYZ coordinates to (Theta,Phi) coordinates;
Last revised on 25 January 2019.