# How to position an object using the w axis from Vector4?

Hey. I have been strugling with this doubt for a while now, and I just can't figure it out.

I'm trying to make a hypercube (also called Tesseract), but I'm having trouble with represanting the w axis in the 3D space. For now, I have a cube that I made using Vector3 vertices (represented as spheres) and a line renderer to connect those vertices.

Now, in order to make the hypercube, I doubled those vertices and changed their object type to Vector4. Now, here's where I'm stuck. I realized that, when I instentiate the vertices, their positioning is being set using only the x, y and z axes. So the new vertices are being created over the other vertices and I just can't figure a way to make Unity consider the w axis.

I know that it's actually impossible to visualize a 4D space, but it's actually possible to kind of "emulate" it in a 3D space. So, should I be using another method? Maybe matrices instead of the Vector3 and 4? Any ideas and help is welcome. Thanks!

Sorry for any misinterpretation, English isn't my best language. Thanks!

I'm not a math guy, but I suppose you may want to define your hypercube as an actual 4d object, u may use custom Vector4 to define vertices. Next stem would be figure out the way to "visualize" your cube in 3d space. Now in 3d space you can't use Vector4 to rappresent vertices but only Vector3. There should be some ready mathematics of how to project 4d object into 3d space, you need to code this "math" so for every given hypercube data input (Vector3, Edges) you get 3d figure data in output (Vector3, Edges, Faces).

You're right that there are means of projecting 4D spaces onto 3D spaces, which Unity would then 'understand' well enough to project onto a 2D display. However, as a consumer of math (not a mathematician of merit), I can say that a Vector4 only resembles a quaternion in the 4 parameters, they are otherwise unrelated. There is an entire algebra associated with quaternions that is entirely separate and with completely unrelated purposes than vectors of 4 parameters (and there are vectors, in pure math study, of more parameters than 4). The basic underlying math of Vector4 is highly related to the math of Vector3, just with more columns or rows when applied to matrices of similar dimensions.

Absolutely right ^^. I was about to mention the same thing. A 4 dimensional euclidean vector is something entirely different from a Quaternion. Quaternions are used to represent rotations or positions in 3d space only. They are represented by a 4 dimensional complex number. Though it can't be use to represent a point in 4d. At least all operations you can do with a quaternion wouldn't make any sense in 4d.

Note that when using Vector4 to represent a 4d point and using a 4x4 matrix to do all transformations you can't perform translations with such a matrix. A matrix transformation can only perform linear transformations on the input vector. So only scaling, rotating and other multiplicative operations (like shear) is possible. We use homogeneous coordindates to be able to perform translations with matricies. Though this always requires one dimension more than your actual spatial dimensions. So to do translations with matrices in 4d you would need a 5x5 matrix and would use Vector5 values. Though these doesn't exist in Unity. Most tesseract simulations use a fixed perspective projection around the origin and the 4d hypercube is located at the origin so no translation is needed.

I recommend to watch this computerphile video on matrices

It's weird I know.. but Just to throw it out there: the fourth dimension need only be orthogonal to the other dimension. This includes TIME. So, a regular cube, that appears at a particular time (position.w), then disappears after a particular time interval (lossyScale.W), COULD be considered a hypercube.

If you need to ANIMATE your hypercube, obviously you cannot ALSO use time as one of your hyper-cubes dimension (they would not be orthogonal): there are actually 5 dimensions required for this if we include time!

**Answer** by JVene
·
Aug 27, 2018 at 11:16 AM

If you've ever studied how 3D space is projected onto a 2D display, you would realize this can't be done by simply stabbing at the problem with a guess. This is a projection. Search the 'net for "how to project 4 dimensional space onto 3 dimensional space" to find a number of references on the math to do this. Once you find that it will become much clearer, but you must understand that describing all that's involved is in fact quite a blog, and won't fit within the limits of a post here. It is a studied subject, and there are some relatively standard approaches within a range of options, just as you find in 3D projections (where various cameras and perspectives are available).

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

Detecting Rays from controller input and cast from Object 0 Answers

What is the best method of creating an element in a 3D environment along a specific axis? 0 Answers

Player Controls For Restricted Directional Movement, but those things vary... 0 Answers

Why aint my gameObject(the one i aplied the script) moving? 1 Answer

I want to make a script that causes the directional light to stop at 180 degrees. 0 Answers