Syntax
c=SGisconvex(SG)
Input Parameter
Output Parameter
c : | | true if convex, false if not |
Copyright 2017-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 algorithm determines whether a given solid geometry (SG) is convex. A solid is considered convex if all normal vectors of its vertices point in the same general direction, meaning the angle between the vector from the center line to a vertex and the vertex normal vector is less than 90 degrees (À/2).
Input Parameters
- SG: Solid Geometry, which includes vertex list (VL) and face list (FL).
Output Results
- c: Boolean value, true if the solid is convex, false otherwise.
Algorithm Steps
- Calculate the center point of the solid using the function
SGgetCenterPoint(SG)
.
- Compute the vector from the center point to each vertex by subtracting the center point from each vertex in the vertex list (VL).
- Normalize these vectors to get unit vectors.
- Create a triangulation object using the face list (FL) and vertex list (VL).
- Calculate the normal vectors for each vertex using the
vertexNormal
function.
- Initialize a zero vector
w
to store angles and set the convexity flag c
to true.
- Iterate over each vertex:
- Calculate the angle between the center line vector and the vertex normal vector using the dot product and
acos
function.
- If any angle is greater than À/2, set
c
to false, indicating the solid is not convex.
- If
c
becomes false and there is an output argument, break the loop early.
- If there is no output argument, plot the solid geometry:
- Set the color to white and transparency to 0.5.
- Plot the solid using
SGplot(SG)
.
- Highlight vertices with angles greater than or equal to À/2 in red.
Algorithm explaination created using ChatGPT on 2025-08-18 23:39. (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