Syntax
RVL=VLswapXY(VL)
Input Parameter
Output Parameter
RVL : | | Rotated vertex list. |
Copyright 2012-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 performs a z-axis rotation by +90 degrees on a vertex list (VL), effectively swapping the x and y coordinates. The function is designed to handle both 2D and 3D vertex lists.
Input Parameters
- VL: The original vertex list, which can be either 2D or 3D. It is an n x 2 or n x 3 matrix where each row represents a vertex with x, y, and optionally z coordinates.
- varargin: An optional parameter that specifies the number of times the rotation should be applied. If not provided, the default is 1.
Output
- RVL: The rotated vertex list, which is the result of applying the z-axis rotation to the input vertex list.
Algorithm Steps
- Initialize the rotation count
r
to 1. If a second argument is provided, set r
to that value.
- For each rotation (from 1 to
r
):
- Check the number of columns in
VL
to determine if it is a 2D or 3D list.
- If
VL
is 2D (n x 2), transform it by swapping the x and y coordinates and negating the new x coordinate: VL = [-VL(:,2) VL(:,1)]
.
- If
VL
is 3D (n x 3), perform a similar transformation while preserving the z coordinate: VL = [-VL(:,2) VL(:,1) VL(:,3)]
.
- Assign the transformed vertex list to
RVL
.
This function is part of the SolidGeometry library and is used for quick 90-degree rotations around the z-axis. It is particularly useful for 2D/3D drawings that require such transformations.
Algorithm explaination created using ChatGPT on 2025-08-19 00:48. (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