-
-
12 May 2015 08:41:33 UTC
- Distribution: Imager-Graph
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Clone git repository
- Issues (18)
- Testers (950 / 0 / 0)
- Kwalitee
Bus factor: 1- 81.59% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (257.03KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Imager
- Test::More
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Imager::Graph::Util - simple geometric functions
SYNOPSIS
my @abc = line_from_points($x1, $y1, $x2, $y2); my @p = intersect_lines(@abc1, @abc2); my @points = intersect_line_and_circle(@abc1, $cx, $cy, $radius);
DESCRIPTION
Provides some simple geometric functions intended for use in drawing graphs.
- line_from_points($x1, $y1, $x2, $y2)
-
Returns the coefficients of a line in the Ax + By + C = 0 form.
Returns the list (A, B, C), or an empty list if they are the same point.
- intersect_lines(@abc1, @abc2)
-
Returns the point of intersection of the 2 lines, each given in Ax+By+C=0 form. Returns either the point (x, y) or an empty list.
- intersect_line_and_circle(@abc, $cx, $cy, $radius)
-
Returns the points or point of intersection of the given line and circle.
INTERNALS
- intersect_line_and_circle()
-
The implementation is a little heavy on math. Perhaps there was a better way to implement it.
Starting with the equations of a line and that of a circle:
(1) Ax + By + C = 0 (2) (x - x1)**2 + (y - y1)**2 = R ** 2 (3) Ax = -By - C # re-arrange (1) (4) A**2 (x - x1)**2 + A**2 (y - y1)**2 = R**2 A**2 # (2) * A**2 (5) (Ax - Ax1)**2 + (Ay - Ay1)**2 = R**2 A**2 # move it inside (6) (-By - C - Ax1)**2 + (Ay - Ay1)**2 = R**2 A**2 # sub (3) into (5)
Expand and convert to standard quadratic form, and similary for x.
Be careful :)
AUTHOR
Tony Cook <tony@develop-help.com>
SEE ALSO
Imager::Graph(3), http://www.develop-help.com/imager/
Module Install Instructions
To install Imager::Graph, copy and paste the appropriate command in to your terminal.
cpanm Imager::Graph
perl -MCPAN -e shell install Imager::Graph
For more information on module installation, please visit the detailed CPAN module installation guide.