- Home /

# 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! Thanks muchly in advance!

**Answer** by ataxkt
·
Apr 15, 2013 at 07:36 PM

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!

**Answer** by Bunny83
·
Apr 15, 2013 at 08:12 AM

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
```

**Answer** by 1337GameDev
·
Apr 14, 2013 at 11:03 PM

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.

**Answer** by whydoidoit
·
Apr 15, 2013 at 08:04 AM

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!

See this: http://en.wikipedia.org/wiki/Rotations_in_4-dimensional_Euclidean_space

**Answer** by aliaksandryemialyanau
·
Nov 01, 2017 at 02:36 PM

Rotation in four-dimensional space.

https://youtu.be/vN9T8CHrGo8 The 5-cell is an analog of the tetrahedron.

https://youtu.be/z_KnvGGwpAo Tesseract is a four-dimensional hypercube - an analog of a cube.

https://youtu.be/HsecXtfd_xs The 16-cell is an analog of the octahedron.

https://youtu.be/1-oj34hmO1Q The 24-cell is one of the regular polytope.

https://youtu.be/w3-TqPXKlVk The hypersphere is an analog of the sphere.

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Procedurally Generated Cube Mesh 3 Answers

Sphere made of cubes algorithm 3 Answers

Highmap on a cube. 0 Answers

Custom Mesh UV Problem 1 Answer

Simple plane generation 1 Answer