Syntax
p=cartofvox(vs,vox)
Input Parameter
vs : | | voxel size [bx by bz] |
vox : | | voxel coordinate vector |
Output Parameter
p : | | cartesian coordinate vector |
Examples
cartofvox([0.2 0.2 1],[2 2 1])
voxofcart([1 1 1],[2.4 2.4 1])
Copyright 2015-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, cartofvox
, converts voxel coordinates to Cartesian coordinates. It is part of the SolidGeometry library and was introduced in version 2.1.
Input Parameters
- vs: A vector representing the voxel size in each dimension, given as [bx, by, bz].
- vox: A vector representing the voxel coordinates, which must be integer values greater than 0.
Output
- p: A vector representing the Cartesian coordinates corresponding to the input voxel coordinates.
Algorithm Steps
- The function first checks if the voxel coordinates are valid. It ensures that all elements of
vox
are integers and greater than 0. If not, it throws an error.
- The voxel coordinates are adjusted by subtracting 1 from each element. This is because voxel indices typically start from 1, but the conversion requires a zero-based index.
- The Cartesian coordinates are calculated by multiplying each adjusted voxel coordinate by the corresponding voxel size dimension. This is done for each dimension (x, y, z).
Example
To convert voxel coordinates [2, 2, 1] with a voxel size of [0.2, 0.2, 1] to Cartesian coordinates, you would call:
cartofvox([0.2, 0.2, 1], [2, 2, 1])
This would return the Cartesian coordinates [0.2, 0.2, 0].
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