Syntax
Tofn([n,poff,woff])
Input Parameter
n : | | 1..36 for an frame; if n==0 a random solution is selected |
poff : | | offset value; default is [0 0 0] |
woff : | | angle osset default is 0 |
Examples
Tofn(11)
Tofn('',[0 100 0], pi/10)
Copyright 2021-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, Tofn, is designed to generate a standardized test frame based on a specified index and optional offsets. It is part of the SolidGeometry library and is used for creating test cases.
Input Parameters
- n: An integer from 1 to 36 that specifies the frame. If n is 0, a random frame is selected.
- poff: A vector [x, y, z] representing the positional offset. The default is [0, 0, 0].
- woff: A scalar representing the angular offset. The default is 0.
Algorithm Steps
- Retrieve the input parameters n, poff, and woff using the getfuncparams function. If n is not provided, it defaults to an empty array.
- Set nmax to 36, representing the maximum number of frames.
- If n is empty, display all 36 frames in a loop using SGfigure and tplot, then return an empty matrix T.
- If n is 0, select a random frame by generating a random number between 1 and nmax.
- Calculate m1 as the modulus of n with 6, and r1 as the integer division of (n-m1) by 6 plus 1.
- Adjust r1 using mod1 to ensure it is within the range of 1 to 6.
- Use a switch statement to determine the ez vector based on m1:
- Case 1: ez = [0, 0, +1]
- Case 6: ez = [0, 0, -1]
- Case 2: ez = [+1, 0, 0]
- Case 5: ez = [-1, 0, 0]
- Case 3: ez = [0, +1, 0]
- Case 4: ez = [0, -1, 0]
- Otherwise: Trigger an error for an invalid code.
- Use another switch statement to determine the angle w based on r1:
- Case 1: w = 0
- Case 2: w = pi/2
- Case 3: w = pi
- Case 4: w = 1.5*pi
- Case 5: w = 2*pi
- Case 6: w = -pi/2
- Otherwise: Trigger an error for an invalid code.
- Calculate the transformation matrix T using the TofPez function with poff, ez, and the sum of w and woff.
- If no output is requested, display the frame using SGfigure and tplot, and label it with the frame number.
Algorithm explaination created using ChatGPT on 2025-08-19 08:19. (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