Syntax
[CPL,cp,d]=CPLsquareline(x,y,d)
Input Parameter
x : | | vector of x-dimension of squares |
y : | | scalar y-dimension of the squares |
d : | | distance between the squares |
Output Parameter
CPL : | | Closed Polygon Line |
cp : | | center points of the boxes. |
d : | | dimensions of boxes that |
Examples
CPLsquareline([1 2 3 4 5],2,1);
Copyright 2019-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, CPLsquareline
, generates a sequence of boxes with varying x-dimensions, arranged in a line with specified distances between them. It is part of the SolidGeometry library.
Input Parameters
- x: A vector containing the x-dimensions of the squares.
- y: A scalar representing the y-dimension of the squares.
- d: The distance between the squares.
Output Results
- CPL: A Closed Polygon Line representing the sequence of boxes.
- cp: The center points of the boxes.
- d: The dimensions of the boxes.
Algorithm Steps
- Initialize an empty list
CPL
and set lx
to 0. Create zero vectors ll
and lm
with the same length as x
.
- Iterate over each element in
x
:
- Generate a square using
PLsquare
with dimensions x(i)
and y
.
- Transform the square using
PLtrans1
.
- Calculate the bounding box of the transformed square using
BBofCPL
.
- Append the transformed square to
CPL
, separated by nan nan
to indicate a break.
- Update
ll(i)
with the current lx
value.
- Calculate the midpoint
lm(i)
of the current box.
- Update
lx
to position the next box, adding the width of the current box and the distance d
.
- Calculate the adjusted distances
d
between the midpoints of consecutive boxes.
- Remove the initial
nan nan
from CPL
.
- Construct the center points
cp
as a matrix with lm
as x-coordinates and zeros as y-coordinates.
- If no output arguments are specified, plot the
CPL
and center points using SGfigure
, CPSplot
, and PLplot
.
Algorithm explaination created using ChatGPT on 2025-08-19 00:24. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21