Name Math::Intersection::Circle::Line - Find the points at which a circle intersects a line. Synopsis use Math::Intersection::Circle::Line; intersectionCircleLine {printf "Intersects at:\n%d, %d\n%d, %d\n", @_ if @_ == 4} 1, 1, 1, # Circle at (1,1) with radius 1 -1, 1, 1, 1; # x, y coordinates of two points on a diagonally crossing line # Intersects at: # 0, 1 # 2, 1 intersectionCircleLine {printf "Tangents touches at\n%d, %d\n", @_ if @_ == 2} 0, 0, 1, # Circle centered on origin with radius 1 -1, 1, 1, 1; # Line along y == 1 # Tangents touches at # 0, 1 intersectionCircleLine {print "No intersection\n" unless @_} 0, 0, 1, # Circle at origin with radius 1 -2, 2, 2, 2; # Line along y == 2 # No intersection Description Find the points at which a circle intersects a line in two dimensions. In two dimensional real space a line intersects the circumference of a circle at two points if the line crosses the circle or at one point if the line is a tangent to the circle or at zero points if the line misses the circle completely. Given a circle specified by the coordinates of its centre and its radius and a line specified by the coordinates of two separate points on the line, "intersectionCircleLine()" calls the subroutine supplied as the first parameter with the coordinates of the points at which the line and circle intersect. If there are two intersection points, 2 pairs of numbers are supplied as parameters. If there is only one intersection point, one pair of numbers is supplied. If there are no intersection points, an empty parameter list is supplied. "intersectionCircleLine()" is easy to use and fast. It is written in 100% Pure Perl. Export The "intersectionCircleLine()" function is exported. Installation Standard Module::Build process for building and installing modules: perl Build.PL ./Build ./Build test ./Build install Or, if you're on a platform (like DOS or Windows) that doesn't require the "./" notation, you can do this: perl Build.PL Build Build test Build install Author Philip R Brenan at gmail dot com http://www.appaapps.com Copyright Copyright (c) 2015 Philip R Brenan. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.