Method for rotating data points in 3 dimensions

Click For Summary

Discussion Overview

The discussion revolves around the problem of rotating data points in a three-dimensional array, specifically focusing on how to rotate blocks represented in a 5x5x5 grid around the center point by 90 degrees in various directions. The context includes both theoretical aspects of rotation matrices and practical applications in a gaming environment.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes a 5x5x5 array representing blocks in a game and seeks a method to rotate these blocks around the center point in any direction by 90 degrees.
  • Another participant questions the terminology used, suggesting that the array may represent voxels rather than points, and proposes using rotation matrices for the calculations.
  • A participant clarifies that the grid consists of binary values (0 for empty, 1 for a block) and emphasizes the need to determine the new coordinates of blocks after rotation, akin to manipulating a Rubik's cube.
  • One participant provides matrix transformations for 90-degree rotations, including both clockwise and counterclockwise rotations, and suggests extending these transformations to higher dimensions.
  • There is mention of needing to apply rotations to each layer of the 5x5 matrices for different axes of rotation.

Areas of Agreement / Disagreement

Participants express differing views on the representation of the data structure (points vs. voxels) and the appropriate methods for performing the rotations. There is no consensus on a single method or approach, and the discussion remains unresolved regarding the best technique to apply.

Contextual Notes

Participants have not fully defined the assumptions regarding the data structure or the specific requirements for the rotation process. The discussion includes various interpretations of how to represent and manipulate the data within the array.

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
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 2 ·
Replies
2
Views
2K