search.cpan.org is shutting down
Yasuhiro Sasama > Math-Bezier-Convert-0.02 > Math::Bezier::Convert
Module Version: 0.02

# NAME

Math::Bezier::Convert - Convert cubic and quadratic bezier each other.

# SYNOPSIS

```  use Math::Bezier::Convert;

@new_cubic = divide_cubic(\$cx1, \$cy1, \$cx2, \$cy2, \$cx3, \$cy3, \$cx4, \$cy4, \$t);
@lines = cubic_to_lines(@cubic);

# DESCRIPTION

Math::Bezier::Convert provides functions to convert quadratic bezier to cubic, to approximate cubic bezier to quadratic, and to approximate cubic and quadratic bezier to polyline.

Each function takes an array of the coordinates of control points of the bezier curve. Cubic bezier consists of one ANCHOR control point, two DIRECTOR control points, one ANCHOR, two DIRECTORS, ... and the last ANCHOR. Quadratic bezier consists of one ANCHOR, one DIRECTOR, ... and the last ANCHOR. The curve pass over the ANCHOR point, but dose not the DIRECTOR point. Each point consists of X and Y coordinates. Both are flatly listed in the array of the curve, like (\$x1, \$y1, \$x2, \$y2, ...).

divide_cubic( \$cx1, \$cy1, \$cx2, \$cy2, \$cx3, \$cy3, \$cx4, \$cy4, \$t )

divides one segment of the cubic bezier curve at ratio \$t, and returns new cubic bezier which has two segment (7 points).

divide_quadratic( \$cx1, \$cy1, \$cx2, \$cy2, \$cx3, \$cy3, \$t )

divides one segment of the quadratic bezier curve at ratio \$t, and returns new quadratic bezier which has two segment (5 points).

approximates cubic bezier to quadratic bezier, and returns an array of the control points of the quadratic bezier curve.

converts quadratic bezier to cubic bezier, and returns an array of the control points of the cubic bezier curve.

cubic_to_lines( @cubic )

approximates cubic bezier to polyline, and returns an array of endpoints.

approximates quadratic bezier to polyline, and returns an array of endpoints.

## GLOBALS

\$Math::Bezier::Convert::APPROX_LINE_TOLERANCE

Tolerance of the distance between the half point of the cubic bezier and the approximation point. Default is 1.

\$Math::Bezier::Convert::CTRL_PT_TOLERANCE

Tolerance of the ANCHOR-DIRECTOR distance ratio of quadratic to cubic. Default is 3. It must be specified more than 1.5.

## EXPORT

None by default. All functions described above are exported when ':all' tag is specified. All global variables are not exported in any case.