Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a very simple voxel engine and so far it works based on coordinates, e.g. x, y, z. I was wondering if there is a formula for rotating groups of voxels/coordinates from the x axis(e.g. [0, 1, 0][1, 0, 1] rotates to [1, 0, 0][0, 0, 1] when rotated 90 degrees anticlockwise along the x axis) from a certain point, but I hear it involves matrixes and quaternions which sound scary.

share|improve this question
up vote 5 down vote accepted

1) The non-scary way to do 90-degree rotations is to swap a set of axes, and negate one of them:

Rotated along x-axis: swap Y/Z to Z/-Y
(a,b,c) -> (a,c,-b)
share|improve this answer
The algorithm is to multiply by a matrix of sin(angle) and cosine(angle). The reason this works in particular is because the sin/cosine of a right angle is 1/0 respectively. There's a series of posts that Wolfire did here:… that may be useful for the full formula. – Jimmy Aug 31 '12 at 18:05

You can't get too far into any 3D programming without matrices or quaternions. It's not too scary though. There are plenty of resources available to you, since you can use some existing resources 3D model transformations. Just think of all your voxel positions as vertex positions.

With that in mind, you can apply a transformation matrix to the voxel positions. However, I imagine you'd want your voxel positions to still align to a grid afterwards, so you'd need to pick your transformations carefully.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.