TofSGez
by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Kinematics and Frames
Introduced first in SolidGeometry 5.2, Creation date: 2022-05-01, Last change: 2025-09-15
finds simple angle by ez vector using SGTsetBF
Description
In contrast to TofSGMLez, this function will find faces with similar angles
See Also: SGTsetBF
, TofSGMLez
, FSselect
, TofcrossedSG
Example Illustration
Syntax
[T,err]=TofSGez(SG,ez,[alp])
Input Parameter
SG: | | Solid Geometry |
ez: | | desired ez vector |
alp: | | allowed deviation; default is pi/4 |
Output Parameter
T: | | Found frame |
err: | | angle difference between ez vectors |
Examples
TofSGMLez(SGsample(3),[0 0 1])
TofSGez(SGsample(3),[0 0 1])
Copyright 2022-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, TofSGez, is designed to find a frame within a solid geometry (SG) that aligns with a desired ez vector, allowing for a specified angular deviation. It is part of the Solid Geometry library and was introduced in version 5.2.
Input Parameters
- SG: The solid geometry object to be analyzed.
- ez: The desired direction vector, typically a 3-element vector. If a 4x4 matrix is provided, the function extracts the third column's first three elements.
- alp: The allowed angular deviation from the desired
ez vector. If not specified, it defaults to pi/4.
Output Results
- T: The transformation matrix representing the found frame.
- err: The angular difference between the desired and found
ez vectors.
Algorithm Steps
- Set the default maximum allowed angle deviation,
maxa, to pi/4.
- Retrieve the
alp parameter from the input arguments, defaulting to maxa if not provided.
- If
ez is a 4x4 matrix, extract the first three elements of the third column.
- Normalize the
ez vector using the normr function.
- Call
SGTsetBF with the solid geometry, the normalized ez vector, and the alp parameter to find a suitable frame T.
- If a frame
T is found, calculate the angular error err as the arccosine of the dot product between the desired and found ez vectors.
- If no frame is found, set
err to alp and calculate T using the mean of the vertices of the solid geometry.
- If no output arguments are specified, plot the solid geometry and the found frame using
SGfigure and SGplotalpha. If the error exceeds alp, plot the frame T.
- Calculate a transformation
T0 that aligns the position of T with the desired ez vector and plot it.
- Print the angular error in degrees using
dbprintf.
Algorithm explaination created using ChatGPT on 2025-08-19 01:28. (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