# RectCoordinatesSub ( pieceA ; pieceB ; materialA ; materialB ; positionX ; positionY )

This topic is 5605 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

Name & Parameters: [color:red][big] RectCoordinatesSub ( pieceA ; pieceB ; materialA ; materialB ; positionX ; positionY ) [/big]

Description: Returns the coordinates of rectangles (with dimensions pieceA x pieceB,) that can be cut from an area of materials (with dimensions materialA x materialB), starting from positionX, positionY.

This is designed to be used by the xmChart plugin to generate a graphic representation of how to cut the most pieces from the material.

This is a sub function of RectCoordinates(), located here (along with a demo)

http://www.fmforums.com/forum/showtopic.php?tid/179077/post/216239/#216239/

Sample Input:

RectCoordinatesSub(12;12;15;25;0;0)

Results:

Recursive: yes

Formula:

```//RectCoordinatesSub ( pieceA ; pieceB ; materialA; materialB; positionX; positionY )

/*

Returns the coordinates of rectangles (with dimensions pieceA x pieceB,) that can be cut from an area of materials (with dimensions materialA x materialB), starting from positionX, positionY.

This is designed to be used by the xmChart plugin to generate a graphic representation of how to cut the most pieces from the material.

Coordinates start from the top, left.

The string returned is in the form:

Sub function of: RectCoordinates().

CFs Required: RectCount(), and DrawRect().

7-29-2006

By Mike Hackett

*/

Let(

[

/*Check the count with first cutting hozontal pieces from horizontal material.*/

countRows = Case(materialA ≥ pieceA and Div(materialB; pieceB) > 0;

Div(materialB; pieceB) +

RectCount(pieceA; pieceB; materialA - pieceA; materialB));

/*Check the count with first cutting vertical pieces from horizontal material.*/

countColumns = Case(materialB ≥ pieceA and Div(materialA; pieceB) > 0;

Div(MaterialA;PieceB) +

RectCount(pieceA; pieceB; materialB - pieceA; materialA))

];

Case(countRows > 0 or countColumns > 0;

Case(countRows > countColumns;

//Draw as many rows as will fit first

DrawRect(positionX; positionY; pieceA; pieceB; "Down"; Div(materialB; pieceB)) &

RectCoordinatesSub( pieceA; pieceB; materialA - pieceA; materialB; positionX + pieceA; positionY );

//Draw as many columns as will fit first

DrawRect(positionX; positionY; pieceB; pieceA; "Across"; Div(materialA;PieceB)) &

RectCoordinatesSub( pieceA; pieceB; materialA; materialB - pieceA; positionX; positionY + pieceA )))

) ```

Required Functions: RectCount()

DrawRect()

Author(s): Ender

Date: 07/29/06

Credits: Based on the discussion in this thread: http://www.fmforums.com/forum/showtopic.php?tid/170643/

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

##### Share on other sites

This topic is 5605 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account