Method for rotating data points in 3 dimensions

Click For Summary
SUMMARY

This discussion focuses on the method for rotating data points in a three-dimensional array, specifically a 5x5x5 voxel grid. The user seeks to rotate these points around the center of the grid by 90 degrees in any direction along the X, Y, or Z axes. Key insights include the use of rotation matrices to achieve the desired transformations, with specific examples provided for both clockwise and counterclockwise rotations. The conversation emphasizes the need for a clear understanding of matrix operations to effectively manipulate the voxel data structure.

PREREQUISITES
  • Understanding of 3D coordinate systems
  • Familiarity with rotation matrices
  • Basic knowledge of voxel data structures
  • Proficiency in programming with arrays
NEXT STEPS
  • Study the mathematical foundations of rotation matrices in 3D space
  • Implement voxel manipulation techniques in a programming language of choice
  • Explore algorithms for rotating 3D objects in computer graphics
  • Research advanced data structures for efficient 3D spatial representation
USEFUL FOR

Game developers, computer graphics programmers, and anyone working with 3D data manipulation will benefit from this discussion, particularly those interested in voxel-based modeling and transformations.

Disputed
Messages
4
Reaction score
0
My best guess is this fits in algebra, I've been scratching my head with this for a while.

I have a three dimensional array representing points of certain objects in a game.

int [5,5,5] currentLocs

I want to be able to rotate these 3d points around the center in any direction by 90 degrees. So like taking a dice and turning from side to side.

In doing it on paper I've noticed that often there's a pattern of finding the difference between the current position in relation to one of the axis not being rotated around and the max value of that axis, but nothing that applies to all points and all rotations.

I want to rotate either direction around any of the three axis and know where each data point should be within the three dimensional array afterwards.

EXAMPLE:

three objects stored as a column with one in a corner in a 3D array
y=2 y=1 y=0
100 000 000
010 010 010
000 000 000

rotated around the X axis would become a horizontal line with the corner object moving to another corner
y=2 y=1 y=0
000 010 100
000 010 000
000 010 000

Any ideas? Most rotation stuff I find involves rotating based on the orientation of a center point and doing matrix multiplication. This works great for rotating a model and what not, but I haven't figured out a way to apply this to my desired technique that can be applied to any cubic odd numbered 3D array. Surely there's some simple proof as to how each coordinate moves to another as the grid rotates.

Thanks
 
Physics news on Phys.org
Disputed said:
I have a three dimensional array representing points of certain objects in a game.

int [5,5,5] currentLocs
So these are voxels? Then it would be misleading to say that they represents points of certain objects in a game. If you truly had an array representing points in a game your array would probably look more like:
int [10,3] currentLocs;
for 10 objects in 3-dimensional space. If this is really what you wanted, then just calculate the rotation matrix for rotation around the appropriate axis (see http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations").

If you really wanted the voxel-based data structure (in which case you should use a much larger array than 5x5x5), then the basic idea is that if you want to do a w rad rotation around some axis you just calculate the appropriate rotation matrix, but instead calculate it for a rotation of -w. Then if you apply it to a point (x,y,z) you find from which voxel that point comes from, and therefore what value to assign to it.

I wouldn't mind providing some more details if you could expand on exactly how your data is represented (are 0 and 1 for instance the only permissible values), and what you're having trouble with.
 
Last edited by a moderator:
Essentially I have a 5x5x5 grid, either 0 (there is nothing) or 1 (there is a block) present. I want to rotate where these blocks are around the center grid point, and this is all stored in the array as mentioned. Every rotation is 90 degrees, hence why I mention moving from side to side or rolling dice. So if I have a block at x,y,z in the array, I want to know how to find the NEW x,y,z based on rotating any of the six possible directions. (clockwise or counter clockwise around each axis). I hope this clarified what I'm trying to do. Like a rubix cube, if I rotate it, I need to know where to move the colors, but not just on the outer walls, also internally in each grip point withe the exception of the center which of course will not move.
 
Here are some matrix transformations that will rotate the elements 90 degrees.
For a clockwise rotation:

B = A^{T} <br /> \[ \left[ \begin{array}{ccc}<br /> 0 &amp; 0 &amp; 1 \\\<br /> 0 &amp; 1 &amp; 0 \\\<br /> 1 &amp; 0 &amp; 0 \end{array} \right]\]

For a counter clockwise rotation:

\medspace B = \[ \left[ \begin{array}{ccc}<br /> 0 &amp; 0 &amp; 1 \\\<br /> 0 &amp; 1 &amp; 0 \\\<br /> 1 &amp; 0 &amp; 0 \end{array} \right]A^{T}

You can extend this to higher dimensions.

For a 5x5x5 array, you could define 3 axis of rotation i,j,k. A rotation around a line through the center of the array and parallel to the k-axis would need a rotation for each of the five layers of 5x5 matricies ( k = 1,2,...,5 ). Similarily for the rotations around the lines through the center and parallel to the i and j axies.
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
3
Views
2K
Replies
9
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 32 ·
2
Replies
32
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K