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

 missing image of TofSGez(SG,ez,alp)

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

Output Results

Algorithm Steps

  1. Set the default maximum allowed angle deviation, maxa, to pi/4.
  2. Retrieve the alp parameter from the input arguments, defaulting to maxa if not provided.
  3. If ez is a 4x4 matrix, extract the first three elements of the third column.
  4. Normalize the ez vector using the normr function.
  5. Call SGTsetBF with the solid geometry, the normalized ez vector, and the alp parameter to find a suitable frame T.
  6. 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.
  7. If no frame is found, set err to alp and calculate T using the mean of the vertices of the solid geometry.
  8. 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.
  9. Calculate a transformation T0 that aligns the position of T with the desired ez vector and plot it.
  10. 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