# Creating a Tesseract - a 4D cube.

Hi all! I’ve got a question which will probably raise more questions than answers, but I’d appreciate any advice I can get.

I’m looking to create a tesseract, which is a 4 dimensional cube. My plan is to create a custom mesh from a set of vertices, and redraw the mesh every time the rotation of the shape changes. I am not worried about precision as this is purely for visual effect(ie - issues such as Gimble Lock can be ignored), and I will only be concerned with rotation, not position.

So - is this theoretically sound?
Would 4D rotations be calculated in a similar way to 3D rotations?
Would the Vector4 be my friend here?
Is anyone aware of any existing c# projects or 4D rotation math?
Once again, sorry for being so vague, this is a very top level question!

Answering my own question, because I’m just that much of a dick. Results can be seen here:
http://tomkail.com/tesseract/
If anyone is interested in the code, let me know! Thanks very much everybody for your support, I’ll be using these forums more!

The easiest way to draw 4D objects in 3D space is to simply introduce another axis. So you would use forward, up and right of a transform as the first 3 axis. Just use another transform’s forward axis as the 4th axis. To calculate a 4D point projected into our 3D space just do this:

``````var axis0 = transform1.forward;
var axis1 = transform1.up;
var axis2 = transform1.right;
var axis3 = transform2.forward;

var pointIn4D = new Vector4(xx,xx,xx,xx);
var projectedPoint = pointIn4D.x*axis0 + pointIn4D.y*axis1 + pointIn4D.z*axis2 + pointIn4D.w*axis3;
``````

You could also setup an projection matrix from the 4 axis. I always get confused if Unity uses column or row multiplication, but in general it would look like:

``````    a0x a1x a2x a3x
a0y a1y a2y a3y
a0z a1z a2z a3z
0   0   0   0
``````

or

``````    a0x a0y a0z 0
a1x a1y a1z 0
a2x a2y a2z 0
a3x a3y a3z 0
``````

I would look up general 4d representations in 3d space. It seems very odd / impractical or even impossible to render a 4d mesh in 3d space.

I would just simulate 4d using a cube inset in another cube. You could also do mesh deformation / small meshes for “pipes” that make up the cube.
This video shows the apparent rotation. Try to simulate what this looks like / does.

Seriously though you are going to need to look at matrices with an extra dimension - so a 4x4 rotates/translates and scales a 3D object - I’m guessing that math will extend to rotating a 4th dimension with a combined isoclinic matrix or something :S. Then you’d need a 4D to 3D projection matrix…

This is a question best answered somewhere where there are proper mathematicians - I still have to read the manual to work out what all the buttons on my calculator do!

Rotation in four-dimensional space.

The 5-cell is an analog of the tetrahedron.

Tesseract is a four-dimensional hypercube - an analog of a cube.

The 16-cell is an analog of the octahedron.

The 24-cell is one of the regular polytope.

The hypersphere is an analog of the sphere.