Syntax
bb=BBofCPS(CPS)
Input Parameter
CPS : | | Colored polyshape struct or polyshape |
Output Parameter
Examples
ps=polyshape(PLcircle(10)), BBofCPS(ps)
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, BBofCPS
, calculates the bounding box for a given polyshape or a colored polyshape struct (CPS). The function is part of the SolidGeometry library and was introduced in version 4.5.
Input Parameters
- CPS: This can be either a colored polyshape struct or a polyshape. If CPS is a struct, it is expected to have a field named 'ps' which contains the polyshape.
Output Results
- bb: The bounding box of the given polyshape or CPS. It is returned as a two-element vector containing the coordinates of the bounding box.
Algorithm Steps
- The function first checks if the input
CPS
is a struct with a field named 'ps'. If so, it assigns the value of CPS.ps
to the variable ps
. Otherwise, it assigns CPS
directly to ps
.
- It then calculates the bounding box of the polyshape
ps
using the boundingbox
function. This function returns two values, a
and b
, which represent the coordinates of the bounding box.
- The bounding box coordinates are combined into a single vector
bb
as [a b]
.
- If no output is requested (i.e.,
nargout==0
), the function proceeds to visualize the results:
- It calls
SGfigure
to create a new figure window.
- It plots the polyshape
ps
using CPSplot
.
- It calculates the closed polygon list (CPL) of the bounding box using
CPLofBB
with a margin of 0.
- Finally, it plots the CPL using
CPLplot
with a blue line of width 2.
Example Usage
An example of how to use the function is provided:
ps = polyshape(PLcircle(10));
BBofCPS(ps);
This example creates a polyshape of a circle with a radius of 10 and calculates its bounding box using the BBofCPS
function.
Algorithm explaination created using ChatGPT on 2025-08-18 22:49. (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