Jeremy schrieb:
> I am looking for an algorithm to rotate a set of voxels in 3d.
Just get three base vectors (the upper 3x3 of the transform matrix).
Then you can iterate through your original data
pseudocode,
given:
3d array voxel[x,y,z],
Vector3f base_x,
Vector3f base_y,
Vector3f base_z
returns:
3d array voxel_new[x,y,z]
Vector3f pos_x=0,0,0
pos_xy, pos_xyz
for x=0 to x_max
{
pos_x=pos_x+base_x
pos_xy=pos_x
for y=0 to y_max
{
pos_xy=pos_xy+base_y
pos_xyz=pos_xy
for z=0 to z_max
{
pos_xyz=pos_xyz+base_z
voxel_new[x,y,z] := voxel[pos_xyz.x, pos_xyz.y, pos_xyz.z]
}
}
}
maybe its an good idea to do this in GLSL to use GPU power for this. but
you can try plain c first.
hope it helps a litte
paul


|