Syntax
rO=reversesortindex(iO)
Input Parameter
Output Parameter
Examples
A=SGbox([30 20 10]);
VL=A.VL, [VL,a]=sortrows(VL), b=reversesortindex(a)
SGfigure; VLFLplot(VL,b(FL),'y');
Copyright 2017-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, reversesortindex
, is designed to compute the reverse sort index for a given sort index. It is part of the SolidGeometry library and was introduced in version 3.9.
Input Parameters
- iO: This is the result of a
sortrows
operation. It is an array that has been sorted, and the function will use this to determine the reverse sort order.
Output Results
- rO: This is the reverse sort order. It is an array that indicates how to reorder the sorted array back to its original order.
Algorithm Explanation
The function works as follows:
- It takes the input array
iO
, which is assumed to be the result of a sortrows
operation.
- It constructs a new matrix by appending a column to
iO
. This new column is a sequence of indices from 1 to the number of elements in iO
.
- The function then applies
sortrows
to this new matrix. The sorting is done based on the original values in iO
, but the result includes the appended indices.
- Finally, the function extracts the second column of the sorted matrix, which contains the indices that map the sorted array back to its original order. This is the reverse sort index
rO
.
Example Usage
Consider the following example:
A = SGbox([30 20 10]);
VL = A.VL;
[VL, a] = sortrows(VL);
b = reversesortindex(a);
SGfigure;
VLFLplot(VL, b(FL), 'y');
In this example, a box is created with dimensions 30x20x10. The vertices list VL
is sorted, and then the reverse sort index is computed using reversesortindex
. Finally, the vertices are plotted in their original order.
Algorithm explaination created using ChatGPT on 2025-08-18 23:00. (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