NAME CAD::Drawing::Calculate - Calculations for CAD::Drawing DESCRIPTION This module provides calculation functions for the CAD::Drawing family of modules. 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. SEE ALSO CAD::Drawing CAD::Calc Math::Vec Changes 0.10 First public release 0.11 Minor improvements Methods Extents Calculations OrthExtents 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); getExtentsRec Alias to OrthExtents() which returns a polyline-form array of points (counter clockwise from lower-left) describing a rectangle. @rec = $drw->getExtentsRec(\%opts); EntOrthExtents 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); @orthfunc List of hash references containing code references to reduce duplication and facilitate natural flow (rather than ifififif statements.) Planar Geometry Methods offset Intended as any-object offset function (not easy). $dist is negative to offset outward $drw->offset($dist); divide $drw->divide(); area $drw->area($addr); Line Manipulations pline_to_ray Transforms a polyline with a nubbin into a ray (line with direction.) $line_addr = $drw->pline_to_ray($pline_addr); trim_both Trims two lines to their intersection. $drw->trim_both($addr1, $addr2, $tol); See CAD::Calc::line_intersection() Coordinate Transforms Switch between coordinate system representations. to_ocs 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 them. $drw->to_ocs($addr); to_wcs Change the objects coordinates into the world coordinate system. $drw->to_wcs($addr); flatten 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 not yet.) $drw->flatten($addr); Functions Non-OO internal-use functions. _ocs_axes Returns the x,y, and z axes for the ocs described by @normal. These will have arbitrary lengths. @local_axes = _ocs_axes(@normal); _wcs_axes Returns the x,y, and z axes for the world coordinate system in terms of the @ocs_axes. @trs_axes = _wcs_axes(@ocs_axes);