Syntax
T=TofP(p)
Input Parameter
p : | | point [x y] or [x y z] |
Output Parameter
T : | | Transformation matrix 3x3 or 4x4 |
Examples
try:
TofP ([0 20])
TofP ([0 20 30])
Copyright 2016-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)
The function TofP
is designed to generate a transformation matrix from a given point in 2D or 3D space. The function can handle both 2D and 3D points and can optionally use a rotation matrix if provided.
Input Parameters
- p: A point represented as a vector. It can be either [x y] for 2D or [x y z] for 3D.
- varargin: Optional parameters, primarily used to pass a rotation matrix
R
.
Output
- T: A transformation matrix. It is 3x3 for 2D points and 4x4 for 3D points.
Algorithm Steps
- Retrieve the rotation matrix
R
from the optional parameters using getfuncparams
.
- If
R
is empty:
- If
p
is a single value, assume it is a z-coordinate and set p
to [0 0 z].
- If
p
has two elements, create a 3x3 identity matrix T
and set the translation part to [x y].
- If
p
has three elements, create a 4x4 identity matrix T
and set the translation part to [x y z].
- If
R
is not empty, call TofR
with R
and p
to compute the transformation matrix T
.
- If no output is requested (
nargout==0
), visualize the transformation:
- For 3D points, plot the transformation matrix
T
and a line from the origin to the translation vector.
- For 2D points, convert the 3x3 matrix to a 4x4 matrix using
T3ofT2
and plot it.
Algorithm explaination created using ChatGPT on 2025-08-19 00:17. (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