**polygon**,
a Python code which
computes properties of an arbitrary polygon in the plane, defined
by a sequence of vertices, including interior angles, area, centroid,
containment of a point, convexity, counter clockwise ordering, diameter,
distance to a point, inradius, lattice area, nearest point in set,
outradius, uniform sampling, and triangulation.

The computer code and data files made available on this web page are distributed under the MIT license

**polygon** is available in
a C version and
a C++ version and
a Fortran90 version and
a MATLAB version and
an Octave version and
a Python version.

ellipse, a Python code which carries out geometric calculations for ellipses and ellipsoids, including area, distance to a point, eccentricity, perimeter, points along the perimeter, random sampling, conversion between standard and quadratic forms.

hypersphere, a Python code which carries out various operations for a D-dimensional hypersphere, including converting between Cartesian and spherical coordinates, stereographic projection, sampling the surface of the sphere, and computing the surface area and volume.

polygon_integrals, a Python code which returns the exact value of the integral of any monomial over the interior of a polygon in 2D.

polygon_monte_carlo, a Python code which applies a Monte Carlo method to estimate the integral of a function over the interior of a polygon in 2D.

polygon_triangulate, a Python code which triangulates a possibly nonconvex polygon, and which can use gnuplot to display the external edges and internal diagonals of the triangulation.

tetrahedron, a Python code which carries out geometric calculations involving a general tetrahedron, including solid and facial angles, face areas, point containment, distances to a point, circumsphere and insphere, measures of shape quality, centroid, barycentric coordinates, edges and edge lengths, random sampling, and volumes.

toms112, a Python code which determines whether a point is contained in a polygon, by Moshe Shimrat. This is a version of ACM TOMS algorithm 112.

triangle, a Python code which computes properties, including angles, area, centroid, circumcircle, edge lengths, incircle, orientation, orthocenter, and quality, of a triangle in 2D.

- polygon.py, calls all the tests.
- polygon.sh, runs all the tests.
- polygon.txt, the output file.

- angle_half.py finds half an angle.
- angle_radian.py returns the angle in radians swept out between two rays.
- i4_ceiling.py returns the smallest I4 that is not smaller than an R8.
- i4_modp.py returns the nonnegative remainder of I4 division.
- i4_wrap.py forces an I4 to lie between given limits by wrapping.
- polygon_angles.py computes the interior angles of a polygon.
- polygon_area.py computes the area of a polygon.
- polygon_area_2.py computes the area of a polygon.
- polygon_centroid.py computes the centroid of a polygon.
- polygon_centroid_2.py computes the centroid of a polygon.
- polygon_contains_point.py finds if a point is inside a simple polygon.
- polygon_contains_point_2.py is a point inside a convex polygon.
- polygon_diameter.py computes the diameter of a polygon.
- polygon_expand.py expands a polygon.
- polygon_inrad_data.py determines polygonal data from its inner radius.
- polygon_integral_1.py integrates the function 1 over a polygon.
- polygon_integral_x.py integrates the function X over a polygon.
- polygon_integral_xx.py integrates the function X*X over a polygon.
- polygon_integral_xy.py integrates the function X*Y over a polygon.
- polygon_integral_y.py integrates the function Y over a polygon.
- polygon_integral_yy.py integrates the function Y*Y over a polygon.
- polygon_is_convex.py determines whether a polygon is convex.
- polygon_lattice_area.py computes the area of a lattice polygon.
- polygon_outrad_data.py determines polygonal data from its outer radius.
- polygon_perimeter.py determines the length of the perimeter of a polygon.
- polygon_perimeter_quad.py estimates the integral of a scalar function over the perimeter of a polygon.
- polygon_point_dist.py distance ( polygon, point ).
- polygon_point_near.py computes the nearest point on a polygon.
- polygon_sample.py returns sample points from a polygon.
- polygon_side_data.py determines polygonal data from its side length.
- polygon_triangulate.py triangulates a polygon.
- r8_atan2.py computes the arc-tangent of a ratio of R8 values.
- r8mat_solve.py uses Gauss-Jordan elimination to solve an N by N linear system.
- r8mat_transpose_print.py prints an R8MAT, transposed.
- r8mat_transpose_print_some.py prints some of an R8MAT, transposed.
- r8vec_print.py prints an R8VEC.
- segment_point_dist.py distance ( line segment, point ).
- segment_point_near.py nearest point on line segment to point.
- timestamp.py prints the current YMDHMS date as a time stamp.
- triangle_area.py computes the area of a triangle.
- triangle_barycentric.py finds the barycentric coordinates of a point.
- triangle_contains_point_1.py finds if a point is inside a triangle.