CAD::Drawing::Calculate - Calculations for CAD::Drawing
This module provides calculation functions for the CAD::Drawing family of
Eric L. Wilhelm <ewilhelm at cpan dot org>
This module is copyright (C) 2004-2006 by Eric L. Wilhelm. Portions copyright
(C) 2003 by Eric L. Wilhelm and A. Zahner Co.
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)
This software is distributed with ABSOLUTELY NO WARRANTY. The author, his former
employer, and any other contributors will in no way be held liable for any
loss or damages resulting from its use.
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.
Calculates the extents of a group of objects (selected according to
select_addr()) and returns an array: [xmin,xmax],[ymin,ymax].
@extents = $drw->OrthExtents(\%opts);
Alias to OrthExtents() which returns a polyline-form array of points
(counter clockwise from lower-left) describing a rectangle.
@rec = $drw->getExtentsRec(\%opts);
Gets the orthographic extents of the object at $addr.
Returns [\@xpts,\@y_pts] (leaving you to sort through them and find which is
min or max.)
@extents = $drw->EntOrthExtents($addr);
List of hash references containing code references to reduce duplication and
facilitate natural flow (rather than ifififif statements.)
Intended as any-object offset function (not easy).
$dist is negative to offset outward
Transforms a polyline with a nubbin into a ray (line with direction.)
$line_addr = $drw->pline_to_ray($pline_addr);
Trims two lines to their intersection.
$drw->trim_both($addr1, $addr2, $tol, \@keep_ends);
Switch between coordinate system representations.
Change the objects coordinates into the object coordinate system.
Both of these are relatively quick. A simple test shows that one
point can be taken back and forth at about 2KHz, so don't be afraid to use
Change the object's coordinates into the world coordinate system.
Puts the object in the wcs, zeros all z-coordinates and deletes the normal
vector. Note that this is fine for projecting polylines and lines, but may not
be what you want if you are trying to make a circle into an ellipse (at least
Non-OO internal-use functions.
Returns the x,y, and z axes for the ocs described by
@normal. These will have arbitrary lengths.
@local_axes = _ocs_axes(@normal);
Returns the x,y, and z axes for the world coordinate system in terms of the
@trs_axes = _wcs_axes(@ocs_axes);