Math::Polygon::Transform3pm
Polygon transformation
Usage
my @poly = ( [1,2], [2,4], [5,7], [1, 2] );my $area = polygon_transform resize => 3.14, @poly;
Inheritance
Math::Polygon::Transformis an Exporter
Overview
This package contains polygon transformation algorithms.
Functions
polygon_grid(%options, @points)-
Snap the polygon points to grid points, where artifacts are removed.
-Option--Defaultraster 1.0- raster => FLOAT
-
The raster size, which determines the points to round to. The origin
"[0,0]"is always on a grid-point. When the raster value is zero, no transformation will take place.
polygon_mirror(%options, @points)-
Mirror the polygon in a line. Only one of the options can be provided. Some programs call this "flip" or "flop".
-Option--Defaultb 0line <undef>rc undefx undefy undef- b => FLOAT
-
Only used in combination with option
"rc"to describe a line.
- line => [POINT, POINT]
-
Alternative way to specify the mirror line. The
"rc"and"b"are computed from the two points of the line.
- rc => FLOAT
-
Description of the line which is used to mirror in. The line is
"y= rc*x+b". The"rc"equals"-dy/dx", the firing angle. If"undef"is explicitly specified then"b"is used as constant x: it's a vertical mirror.
- x => FLOAT
-
Mirror in the line
"x=value", which means that"y"stays unchanged.
- y => FLOAT
-
Mirror in the line
"y=value", which means that"x"stays unchanged.
polygon_move(%options, @points)-
Returns a list of points which are moved over the indicated distance
-Option--Defaultdx 0dy 0- dx => FLOAT
-
Displacement in the horizontal direction.
- dy => FLOAT
-
Displacement in the vertical direction.
polygon_resize(%options, @points)-
-Option--Defaultcenter [0,0]scale 1.0xscale <scale>yscale <scale>- center => POINT
- scale => FLOAT
-
Resize the polygon with the indicated factor. When the factor is larger than 1, the resulting polygon with grow, when small it will be reduced in size. The scale will be respective from the center.
- xscale => FLOAT
-
Specific scaling factor in the horizontal direction.
- yscale => FLOAT
-
Specific scaling factor in the vertical direction.
polygon_rotate(%options, @points)-
-Option --Defaultcenter [0,0]degrees 0radians 0- center => POINT
- degrees => FLOAT
-
specify rotation angle in degrees (between -180 and 360).
- radians => FLOAT
-
specify rotation angle in rads (between -pi and 2*pi)
polygon_simplify(%options, @points)-
-Option --Defaultmax_points undefsame 0.0001slope undef- max_points => INTEGER
-
First,
"same"and"slope"reduce the number of points. Then, if there are still more than the specified number of points left, the points with the widest angles will be removed until the specified maximum number is reached.
- same => FLOAT
-
The distance between two points to be considered "the same" point. The value is used as radius of the circle.
- slope => FLOAT
-
With three points X(n),X(n+1),X(n+2), the point X(n+1) will be removed if the length of the path over all three points is less than
"slope"longer than the direct path between X(n) and X(n+2).The slope will not be removed around the starting point of the polygon. Removing points will change the area of the polygon.
Diagnostics
- Error: you need to specify 'x', 'y', 'rc', or 'line'
Releases
8 releases since Debian 6.0 (Squeeze); the text changed 6 times.