toms112, a MATLAB code which determines whether a point is inside a polygon.

The text of many ACM TOMS algorithms is available online through ACM: or NETLIB:


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


toms112 is available in a C version and a C++ version and a FORTRAN90 version and a MATLAB version and a Python version.

Related Software and Data:

geometry, a MATLAB code which performs geometric calculations in 2, 3 and N dimensional space.

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

polygon_properties, a MATLAB 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, diameter, distance to a point, inradius, lattice area, nearest point in set, outradius, uniform sampling.

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



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

Source Code:

Last revised on 01 March 2019.