Method for rotating data points in 3 dimensions

In summary, the conversation is about finding a way to rotate a three dimensional array representing points in a game, where 0 represents nothing and 1 represents a block, by 90 degrees in any direction around the center. This can be achieved using rotation matrices, with different matrices needed for different axis of rotation. The specific details and transformations needed for a 5x5x5 array are also discussed.
  • #1
Disputed
4
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
  • #2
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:
  • #3
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.
 
  • #4
Here are some matrix transformations that will rotate the elements 90 degrees.
For a clockwise rotation:

[tex]B = A^{T}
\[ \left[ \begin{array}{ccc}
0 & 0 & 1 \\\
0 & 1 & 0 \\\
1 & 0 & 0 \end{array} \right]\][/tex]

For a counter clockwise rotation:

[tex]\medspace B = \[ \left[ \begin{array}{ccc}
0 & 0 & 1 \\\
0 & 1 & 0 \\\
1 & 0 & 0 \end{array} \right]A^{T}[/tex]

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.
 
  • #5
for your question and for sharing your thoughts on this problem. I can offer some insights and suggestions on how to approach this method for rotating data points in 3 dimensions.

First, it's important to understand the concept of rotation in three dimensions. In a three-dimensional space, we have three axes - x, y, and z - and an object can be rotated around each of these axes. This means that for any given point in 3D space, we need to know its coordinates along these three axes in order to rotate it.

In your example, you have a 3D array representing points in a game. Each point has three coordinates - x, y, and z - indicating its position along each axis. To rotate these points, we need to determine how their coordinates will change after rotation.

One approach to solving this problem is to use matrix multiplication, as you mentioned. This involves creating rotation matrices for each axis (x, y, and z) and multiplying them with the original coordinates of each point. This will give you the new coordinates after rotation.

Another approach is to use quaternion rotation. Quaternions are mathematical entities that can represent rotations in three dimensions. They are often used in computer graphics and game development for their efficiency and accuracy. By using quaternion rotation, you can easily rotate points around any axis and in any direction.

In terms of finding a pattern or formula for rotating points in a 3D array, it's important to note that the rotation will depend on the specific axis and direction of rotation. This means that there may not be a single formula that can be applied to all points and all rotations. Instead, you may need to use a combination of rotation matrices or quaternions to achieve the desired rotation for each point.

In summary, rotating data points in 3 dimensions can be achieved using matrix multiplication or quaternion rotation. It's important to understand the concept of rotation and to use the appropriate method for the desired rotation. There may not be a single formula that can be applied to all points and all rotations, so a combination of techniques may be needed. I hope this helps in your understanding and approach to this problem.
 

1. What is the purpose of rotating data points in 3 dimensions?

The purpose of rotating data points in 3 dimensions is to change the orientation of a dataset in order to better visualize and analyze it. This can help identify patterns, relationships, and anomalies that may not be apparent in the original orientation of the data.

2. How is rotation of data points in 3 dimensions performed?

Rotation of data points in 3 dimensions is typically performed using mathematical transformations such as rotation matrices or quaternions. These transformations involve changing the coordinates of each data point based on the desired rotation.

3. What are some common applications of rotating data points in 3 dimensions?

Rotating data points in 3 dimensions is commonly used in various fields such as computer graphics, computer vision, and data analysis. It can be used to create 3D visualizations, align images or objects, and analyze spatial data.

4. Can data points be rotated in multiple dimensions?

Yes, data points can be rotated in multiple dimensions. However, the process becomes more complex as the number of dimensions increases. In 3D, data points can be rotated around three axes (x, y, and z), while in higher dimensions, they can be rotated around multiple axes.

5. Are there any limitations to rotating data points in 3 dimensions?

One limitation of rotating data points in 3 dimensions is that it may introduce distortion or loss of information. This is because rotating the data changes the original coordinates and relationships between data points. Additionally, it may not be suitable for all types of data, such as categorical data or data with irregular shapes.

Similar threads

  • Sci-Fi Writing and World Building
Replies
9
Views
2K
  • Classical Physics
Replies
6
Views
630
  • Linear and Abstract Algebra
Replies
13
Views
2K
Replies
3
Views
2K
  • Linear and Abstract Algebra
Replies
1
Views
925
  • Advanced Physics Homework Help
Replies
5
Views
902
Replies
2
Views
1K
  • Introductory Physics Homework Help
Replies
5
Views
1K
Replies
9
Views
877
Replies
3
Views
1K
Back
Top