ZLab.Discrete ZLab.Discrete
ZLab.Discrete ZLab.Discrete
Developed by Zeke Zhang

Search Results for

    Edit this page

    Method WorldToVoxelIndex

    | Edit this page View Source

    WorldToVoxelIndex(Vector3, Vector3)

    Converts world position to voxel grid index. Use for normal coordinate conversion.

    Declaration
    public static (int x, int y, int z) WorldToVoxelIndex(Vector3 worldPosition, Vector3 voxelSize)
    Parameters
    Type Name Description
    Vector3 worldPosition

    The world position to convert

    Vector3 voxelSize

    The size of each voxel in world units

    Returns
    Type Description
    (int x, int y, int z)

    The (x, y, z) grid indices of the containing voxel

    | Edit this page View Source

    WorldToVoxelIndex(Vector3, Vector3, Vector3)

    Converts world position to voxel grid index with custom grid origin. Use for normal coordinate conversion.

    Declaration
    public static (int x, int y, int z) WorldToVoxelIndex(Vector3 worldPosition, Vector3 voxelSize, Vector3 gridOrigin)
    Parameters
    Type Name Description
    Vector3 worldPosition

    The world position to convert

    Vector3 voxelSize

    The size of each voxel in world units

    Vector3 gridOrigin

    The world position of the grid's origin (minimum corner of voxel (0,0,0))

    Returns
    Type Description
    (int x, int y, int z)

    The (x, y, z) grid indices of the containing voxel

    | Edit this page View Source

    WorldToVoxelIndex(float, float, float, in Vector3)

    Converts world position to voxel grid index. Use for normal coordinate conversion.

    Declaration
    public static (int x, int y, int z) WorldToVoxelIndex(float x, float y, float z, in Vector3 voxelSize)
    Parameters
    Type Name Description
    float x

    The X world coordinate

    float y

    The Y world coordinate

    float z

    The Z world coordinate

    Vector3 voxelSize

    The size of each voxel in world units

    Returns
    Type Description
    (int x, int y, int z)

    The (x, y, z) grid indices of the containing voxel

    Remarks

    This overload is provided for performance in tight loops to avoid Vector3 construction.