Quick Navigator

 Search Site Miscellaneous Server Agreement Year 2038 Credits

# DESCRIPTION

This module provides calculation functions for the CAD::Drawing family of modules.

# AUTHOR

Eric L. Wilhelm <ewilhelm at cpan dot org>

http://scratchcomputing.com

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)
(found at http://www.perl.com/pub/language/misc/Artistic.html)
```

# NO WARRANTY

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.

# 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.

```  CAD::Drawing
Math::Vec
```

# 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(\$object, \$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, \@keep_ends);
```

# 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 object's 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);
```
 2022-06-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.