SGcenter

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Spatial Relations
Introduced first in SolidGeometry 4.7, Creation date: 2019-07-12, Last change: 2025-09-14

centers a solid on the x y or z axis



See Also: SGrotate , SGTransT

Example Illustration

 missing image of SGcenter(SG,cstr)

Syntax

SG=SGcenter(SG,[cstr])

Input Parameter

SG: Solid Geometry
cstr: center string such as 'xyz'

Output Parameter

SG: Centered Solid

Examples


SGbox; A=ans; SGtrans1(A); B=ans;
SGcenter(B,'x')
SGcenter(B,'xz')
SGcenter(SGoftext('test'),'xyz')




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, SGcenter, is designed to center a solid geometry (SG) along specified axes (x, y, z) based on a given center string (cstr).

Input Parameters

Output

Algorithm Steps

  1. Retrieve the center string (cstr) from the input parameters, defaulting to 'xyz' if not provided.
  2. Calculate the bounding box (bb) of the solid geometry using the function BBofSG(SG).
  3. Determine the size of the bounding box (ss) using sofBB(bb).
  4. Initialize a translation vector P as [0 0 0].
  5. Iterate over each character in the center string (cstr):
  6. If no output arguments are specified, plot the centered solid using SGfigure and SGplotalpha(SG) with a view angle of (-30, 30).
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