Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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

2 Answers 2

up vote 4 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
1  
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: blog.wolfire.com/2010/07/… that may be useful for the full formula. –  Jimmy Aug 31 '12 at 18:05
    
Ah. Many thanks, this explains everything. I would vote this up but I don't have enough rep yet lol, but thanks :D –  Luke Aug 31 '12 at 21:03

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

 
discard

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.