Syntax
bb=BBofPS(ps)
Input Parameter
Output Parameter
Examples
ps=polyshape(CPLsample(33)); plot(ps)
BBofPS(ps)
Copyright 2018-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, BBofPS
, calculates the bounding box of a given polyshape. It is part of the SolidGeometry library and is designed to be faster than the standard MATLAB implementation.
Input Parameters
- ps: A polyshape object representing a polygon.
Output Results
- bb: A vector representing the bounding box of the polyshape. It contains the coordinates of the lower-left and upper-right corners of the bounding box.
Algorithm Steps
- The function first attempts to calculate the bounding box using the vertices of the polyshape by calling
BBofCPL(ps.Vertices)
. This method is noted to be twice as fast.
- If the above line is commented out, the function uses MATLAB's built-in
boundingbox
function to calculate the bounding box. This method is slower.
- The result is stored in the variable
bb
, which is a combination of the lower-left and upper-right corner coordinates.
- If no output argument is specified (
nargout==0
), the function will:
- Create a new figure using
SGfigure
.
- Plot the polyshape using
plot(ps)
.
- Plot the bounding box using
CPLplot(CPLofBB(bb,0),'r-',2)
, which draws the bounding box in red with a line width of 2.
Example Usage
An example is provided where a polyshape is created using CPLsample(33)
, plotted, and its bounding box is calculated using BBofPS(ps)
.
Algorithm explaination created using ChatGPT on 2025-08-18 22:48. (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