numerical programming - - ap3
numerical programming - - ap3
The PieceOutLine class's methods use Bezier curves to create intricate shapes, depending on
whether they are for the right, left, top, or bottom portions of a piece. The PieceInfo class
arranges the pieces in a grid and determines their types. Then, the polygonCropImage
function is used to crop out the piece shapes from an image.
The result is a set of interconnected pieces that could be used in a puzzle, board game, or
similar application where custom-shaped pieces need to fit together based on their borders.
- code uses cubic Bezier curves to generate smooth curves between points. This is done through
the computeBezierPoint and computerBezier functions, where computeBezierPoint computes
a specific point on the curve, and computerBezier computes the entire curve by iterating
through a range of t values.
- The PieceOutLine class is responsible for generating the outline of a single piece. The outline
consists of a series of points that describe the boundary of the piece, which is created using
combinations of arc segments and connections.
- The PieceInfo class is used to manage the grid of pieces. Given a size, number of rows, and
columns, it calculates the boundaries and type of each individual piece.
- The polygonCropImage function crops an image by creating a mask from a polygon
(presumably the shape of the piece) and using that mask to cut out the corresponding part of
the image.
- PieceOutLine generates the specific shape for each piece, based on parameters like width,
height, arc ratio, and connection ratio.
PieceInfo provides grid-level information about how pieces should be arranged, such as
determining whether a piece is male or female and managing connections between pieces.