Syntax
vox=voxofcart(vs,p)
Input Parameter
vs : | | voxel size [bx by bz] |
p : | | cartesian coordinate vector |
Output Parameter
vox : | | voxel coordinate vector |
Examples
voxofcart([1 1 1],[2.4 2.4 1])
cartofvox([0.2 0.2 1],[2 2 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, voxofcart
, converts Cartesian coordinates to voxel coordinates. It is part of the SolidGeometry library and was introduced by Tim Lueth in 2015.
Input Parameters
- vs: A vector representing the voxel size in the x, y, and z dimensions, denoted as [bx by bz].
- p: A vector of Cartesian coordinates that need to be converted to voxel coordinates.
Output
- vox: A vector of voxel coordinates corresponding to the input Cartesian coordinates.
Algorithm Explanation
The function calculates the voxel coordinates by performing the following steps:
- Divide each component of the Cartesian coordinate vector
p
by the corresponding component of the voxel size vector vs
. This is done for each dimension (x, y, z).
- Add 1.5 to each of the resulting values. This step is likely used to ensure proper rounding when converting to integer voxel coordinates.
- Apply the
floor
function to each of the adjusted values. The floor
function rounds each value down to the nearest integer, effectively converting the adjusted Cartesian coordinates to voxel coordinates.
Example
For example, calling voxofcart([1 1 1],[2.4 2.4 1])
will return the voxel coordinates by dividing each component of the Cartesian coordinates by the voxel size, adding 1.5, and then flooring the result.
Algorithm explaination created using ChatGPT on 2025-08-18 22:10. (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