BBofPS

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Geometric Queries
Introduced first in SolidGeometry 4.4, Creation date: 2018-12-31, Last change: 2025-09-14

returns the bounding box of a polyshape

Description

2018a - faster than the matlab implementation

See Also: CPLofBB , BBofVL , BBofSG , BBofCPS , BBofCPL , BBofSGcutT

Example Illustration

 missing image of BBofPS(ps)

Syntax

bb=BBofPS(ps)

Input Parameter

ps: polyshape

Output Parameter

bb: bounding box

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

Output Results

Algorithm Steps

  1. 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.
  2. 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.
  3. The result is stored in the variable bb, which is a combination of the lower-left and upper-right corner coordinates.
  4. 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