Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by ataxkt · Apr 14, 2013 at 10:51 PM · meshproceduralcube4d

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!

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Apr 15, 2013 at 07:14 AM 0
Share

Look, there are no "4D objects". It's just an abstraction by mathematicians.

In different conventionalities, you can talk about the projection of 4D objects on to 3D. (Just as - depending on how you look at it - the "projection" of a sphere on to 2D could, in some situations, be said to be a circle.)

So all you're talking about is "rendering some 3D shape".

Yes, you can render absolutely any 3D shape or object, whatsoever, in Unity.

O$$anonymous$$?

It would be like if you asked "I'm looking at drawing < some particular mathematical abstraction related to 3D objects > on a piece of paper, can I do that?"

Yes, you can draw any 2D drawing, whatsoever, on paper.

Yes, you can render any 3D object, whatsoever, in Unity.

For math discussion on 4D shapes, etc, math-stackexchange site

5 Replies

· Add your reply
  • Sort: 
avatar image
6
Best Answer

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!

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image whydoidoit · Apr 15, 2013 at 07:38 PM 1
Share

You should definitely answer your own question!

It would be great to get a description of how you did it...

avatar image ataxkt · Apr 15, 2013 at 07:53 PM 2
Share

In short, I ported the code from the link at the bottom of the page. In long: A list of Vector4s is created, and filled with a value for each vertices of a tesseract, of which there are 16 (essentially two cubes of 8 verts, with the second cube's w axis inverted).

 verts = new List<Vector4>(){
        new Vector4(1,1,1,1),
        new Vector4(1,1,1,-1),
        new Vector4(1,1,-1,1),
        new Vector4(1,1,-1,-1),
     .....

Rotations are carried out over different axis and stored in a list of rotations (ins$$anonymous$$d of using the GO's Transform, which is three-dimentional).

The rotations are calculated using a matrix (which can be found in $$anonymous$$ilosz code).

Lastly, I draw planes to fill all 24 faces of the tesseract using the vert array (where the 4D verts are treated as 3D verts).

And that's it! The code can be found at this link.

avatar image WillNode · Apr 22, 2015 at 12:45 PM 0
Share

Hi, I know that this is old post, but I've got different method to create 4D Objects in unity, also it's supported to create another 4D Objects from any 3D $$anonymous$$eshes. check it here.

and anyway, your tesseract is awesome too!, just want to see how did you calculate that.

avatar image ataxkt · Apr 24, 2015 at 07:41 PM 0
Share

Oh wow! That tool looks amazing. I don't suppose you'd consider sending me a copy of your tool? I'd love to have a play!

avatar image WillNode · Apr 24, 2015 at 08:00 PM 0
Share

my code just simply duplicate two meshes together and then interpolating it with this code :

 Vector3 DiffA = Vector3.Lerp (Vector3.zero,m_wOffset,m_wPivot);
 Vector3 DiffB = Vector3.Lerp (m_wOffset,Vector3.zero,m_wPivot);
 float FacA = $$anonymous$$athf.Lerp (1, m_wScale,m_wPivot);
 float FacB = $$anonymous$$athf.Lerp (m_wScale,1, m_wPivot);
             
 mesh.vertices =    
     System.Array.ConvertAll (oriVert, x => vRot (x * FacA + DiffA , m_wRotation,  x)).Concat(  // First $$anonymous$$esh
     System.Array.ConvertAll (oriVert, x => vRot (x / FacB - DiffB , m_wRotation,  x))).ToArray(); //Second $$anonymous$$esh
 // OriVert -> Original Vertices
 // vRot(Axis, Input, Pivot) -> Rotating Vector3 with Quaternion
 mesh.RecalculateBounds ();

well actually I'm trying to upload the webplayer but I get limited budget (Dropbox need Pro ones) so I still looking for alternatives one.

Show more comments
avatar image
2

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
Comment
Add comment · Show 5 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Apr 15, 2013 at 08:17 AM 1
Share

Like others already said there is not "right" way to draw a hypercube in 3D space since that's not possible. You can only draw an projection of it in a certain state. Like 3D can't be displayed on a 2D screen. It's only a projection of the current viewing angle.

avatar image Bunny83 · Apr 15, 2013 at 08:19 AM 0
Share

Take a look at this:

http://www.youtube.com/watch?v=ccws454YiV$$anonymous$$

avatar image Fattie · Apr 15, 2013 at 08:35 AM 0
Share

Just as Bunny says ...

even what we think of as a "2D image" is just one mathematical approach, an abstraction, an idea, of a way to do it.

Sure, it's sort of roughly what Vermeer invented or (in some sense) our eyeballs do, but it has no real meaning.

Indeed note that, immediately, Unity presents two utterly different ways to map 3D to 2D - both of which are there simply because "those two particular choices happen to be common in video games"

avatar image ataxkt · Apr 15, 2013 at 09:23 AM 0
Share

Thanks for the advice everyone! You are of course correct about the 2d/3d reprentation analysis - I think Carl Segan called a 3d model of a 4d shape a 3d shadow - so I guess that makes this a 2d shadow of a 3d shadow of a 4d shape! I'll have a closer look at the matrices and the wiki link when I get home. This link http://hypersolid.milosz.ca/ best explains the effect I'm looking for. Looking through the code, it seems that the verts are being rotated using a simple looking 4D rotation matrix around 6 different axis, which is interesting. I because rotations are not stored in the GO's transform, I will need to change the stored rotation in relation the camera (unless I went for a custom camera setup), but I'll ignore that for now. Its probably not the best way to go about it, but I'll attempt to port it into Unity later on - I'll post a link if I have any success.

avatar image Fattie · Apr 15, 2013 at 09:30 AM 0
Share

I LOVE Carl Sagan, man !

I have an old-school boxed-set of Cosmos, even.

I suggest everyone just takes an hour off an watches this!

http://www.youtube.com/watch?v=dADUBcoEEHw

What a great guy.

the new world's greatest TV moment. Hooray, Carl Sagan.

avatar image
1

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.

Youtube video showing rotation

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ataxkt · Apr 14, 2013 at 11:14 PM 0
Share

Surely the existence of that video proves it possible? You are correct about it being difficult to render in 3D space though - I'm not sure how the shape would cope with camera rotation :/ The two cube idea would work if the hypercube did not rotate (two cubes being the "foundation" of the shape anyway), and the pipes idea would still rely on drawing from a set of 4D rotated verts as I proposed above.

avatar image whydoidoit · Apr 15, 2013 at 08:00 AM 0
Share

It's actually being rendered in 2D space right, via the projection to the screen :) Could just go the whole way right?

avatar image
1

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ataxkt · Apr 15, 2013 at 09:34 AM 0
Share

Looks like a great (and really confusing) link. I'll take a look later! Thanks.

avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Procedurally Generated Cube Mesh 3 Answers

Sphere made of cubes algorithm 4 Answers

Highmap on a cube. 0 Answers

Custom Mesh UV Problem 1 Answer

Simple plane generation 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges