NAME
CAD::Calc -- generic cad-related geometry calculations
AUTHOR
Eric L. Wilhelm
ewilhelm at sbcglobal dot net
http://pages.sbcglobal.net/mycroft
COPYRIGHT
This module is copyright (C) 2003 by Eric L. Wilhelm and A. Zahner Co.
LICENSE
This module is distributed under the same terms as Perl. See the Perl source package for details.
You may use this software under one of the following licenses:
(1) GNU General Public License
(found at http://www.gnu.org/copyleft/gpl.html)
(2) Artistic License
(found at http://www.perl.com/pub/language/misc/Artistic.html)
NO WARRANTY
This software is distributed with ABSOLUTELY NO WARRANTY. The author and his employer will in no way be held liable for any loss or damages resulting from its use.
Modifications
The source code of this module is made freely available and distributable under the GPL or Artistic License. Modifications to and use of this software must adhere to one of these licenses. Changes to the code should be noted as such and this notification (as well as the above copyright information) must remain intact on all copies of the code.
Additionally, while the author is actively developing this code, notification of any intended changes or extensions would be most helpful in avoiding repeated work for all parties involved. Please contact the author with any such development plans.
Functions
These are all exported as options.
distdivide
Returns a list of point references resulting from dividing $line into as many parts as possible which are at least $dist apart.
@points = distdivide(\@line, $dist);
subdivide
Returns a list of point references resulting from subdividing $line into $count parts. The list will be $count-1 items long, (does not include $line->[0] and $line->[1]);
$line is of the form: [ [x1, y1, z1], [x2, y2, z2] ] where z1 and z2 are optional.
@points = subdivide($line, $count);
shorten_line
Shortens the line by the distances given in $lead and $tail.
@line = shorten_line(\@line, $lead, $tail);
dist
Returns the direct distance from ptA to ptB.
dist($ptA, $ptB);
dist2d
Purposefully ignores a z (2) coordinate.
dist2d($ptA, $ptB);
signdist
Returns the signed distance
signdist(\@ptA, \@ptB);
offset
Creates a contour representing the offset of @polygon by $dist. Positive distances are inward when @polygon is ccw.
@polygons = offset(\@polygon, $dist);
intersection_data
Calculates the two numerators and the denominator which are required for various (seg-seg, line-line, ray-ray, seg-ray, line-ray, line-seg) intersection calculations.
($k, $l, $d) = intersection_data(\@line, \@line);
line_intersection
Returns the intersection point of two lines.
@pt = line_intersection(\@line, \@line);
Determinant
Determinant($x1, $y1, $x2, $y2);
pgon_angles
Returns the angle of each edge of polygon in xy plane.
Not functioning
@angles = pgon_angles(@points);
isleft
Returns positive if @point is left of @line.
isleft(\@line, \@point);
unitleft
Returns a unit vector which is perpendicular and to the left of @line. Purposefully ignores any z-coordinates.
$vec = unitleft(@line);