Archived

This topic is now archived and is closed to further replies.

4th Demension...

This topic is 5869 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Umm, ok i am pretty new to openGL, but not that new. I am going to write a program for my math class, showing a cube rotating in the 4th demension. If you can see this, its 2 cubes, one bigger then the other, and the inside one is getting bigger, and the outside one is getting smaller, then it goes back and forth like that. I know rotation, but making them boxes is just alittle problum... maybe its just me, and im dumb, but how do i draw like a BOX!!! and second, how would i get these 2 boxes to invert like how i described?!! Please help! slim475@hotmail.com is my email, if you wanna help. I wil check the board in a few days. Peace

Share this post


Link to post
Share on other sites
one more thing, when i said draw a box, i ment like lines, not like a side. i can easily open .bmp pictures, but i wanted just the lines. O ya, and i need the boxes to be connected by skew vertex (or parallel, if you like that name better)

i hope you can understand

Share this post


Link to post
Share on other sites
quote:
Original post by DarkHunter
...showing a cube rotating in the 4th demension.

Just thought you might like to know that the proper mathematical name for what you describe is tesseract or hypercube (it is to a [3D] cube as a cube is to a square; there are also actually 8 cubes involved. There is an open source OpenGL-based screensaver that implements this for Linux. You could take a look at the sources to see how it was implemented; it''s by Jamie Zawinski, for the xscreensaver framework. (There''s screenshots on the site)



I wanna work for Microsoft!

Share this post


Link to post
Share on other sites
I know its hyper cube. I wasn''t sure if anybody else would know what i ment. Look, i have looked At the guides, but nothing on the site can help me with the 4th deminsion.

i will check the screen saver thing, thanks!

Share this post


Link to post
Share on other sites
Maybe what you want is a projection matrix? OpenGL won''t render things in 4D too well, but if you take some 4-D coords and project them down to 3-space, and then of course to the 2-space of your monitor, you should get the same effect. A simple way to do this might be to use the weighting factor that OpenGL uses in all it''s vertices. Do like so:
glFloat v1[] = { -1, -1, -1, -1 };
glFloat v2[] = { 1, -1, -1, -1};
glFloat v3[] = { -1, 1, -1, -1};
glFloat v4[] = { 1, 1, -1, -1};
...

Then, you can use the glVertex4f command, like so:
glVertex4fv(v1);
glVertex4fv(v2);
...

This might actually not work, since the opengl 4th coord is not really seen as being a spatial coordinate but a weighting factor. A more accurate way to do this is to make your own projection matrix and run all the 4D verts through that. I think that to do this, you need to figure out what solid you wish your hypercube to be projected onto, and then make a 5x5 projection matrix that will map the 4-space vectors, plus a weighting factor, to that solid. If you want more help, I can try to make the matrix, but it might be a fun excersize for you

Share this post


Link to post
Share on other sites
quote:
Original post by tsuraan
...OpenGL won''t render things in 4D too well...



The 4th dimension is purely theoretical; some consider it in physical terms as a 4th spatial dimension, while others consider it to be temporal. In other words, nothing will render 4D things well.

The hypercube is a projection of the unfolded 4D figure into 3D space. In other words, he''s performing normal 3d operations.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Here is what i define and my teacher defines as a hypercube:

Just image a square: 4 lines, each line touches 2 other lines
im sure you can still see this
Now a cube: 6 square, each square touches 4 other squares
still following?
Now a hypercube: 8 cubes, each cube touches 6 other cubes
say what?!
try drawing that out!

Share this post


Link to post
Share on other sites
I''ve seen a line based "3d" hypercube before, doing only line art, I think i''ve seen what your talking about before on the web, either as a java app or a animated gif. The best way i can describe the motion is 2 cubes, one inside the other in all (3) dimensions, and the cubes are connected by lines at the corners. So the front left corner of the inner box is connected to the front left corner of the outer box. Then the inside rolls/evolves so the inside is now the outside, and so on.
As far as setting up the polygons, that''s a little bit beyond me, but this site may or may not shine some lit on it, throug you''ve probably allready seen this information in class.
http://members.tripod.de/jkoeller/hypercube.htm
along with a site with lots of links
http://www.cs.mu.oz.au/~amb/4d/
A 3d movie of a hypercube/dice compard to a regular dice
http://www.cica.indiana.edu/projects/4Dice/movies.html
If this is your first forray into 3D at all I really really Don''t recommend tackling this now, it is tough to get a good understanding of 3D, never mind animating 3D perspectives of 4D objects.
If you do have time, the best way to go about this is to know the language you intend to do this is, OpenGL so c++, now the OS win/mac/linux, setup simple 3D box that you can rotate and understand what is happening, the elaborate the model to either fake a hypercube or actually model a hypercube and do what tsuraan suggested and pass the 4d cords through a projection matrix so give you 3d cords, (which then get passed to opengl which then converts them to 2d cords to be displayed)
if new to windows
http://www.gamedev.net/reference/programming/features/gpgenesis1/
if new to opengl
http://nehe.gamedev.net
if new to 3d
http://www.gamedev.net/hosted/3dgraphics/

Hope this helps, or at least gives you an idea of what your doing. I''m sorry if you know this stuff, i wasn''t quite sure what your proficiany with any of this is.

Share this post


Link to post
Share on other sites
Ok, now i have a new question for you guys. Should i make 8 seprate cubes, OR make the 2 and connect the vetexs and have it constintally moving. At any rate, i hope sombody thinks of it fo me, i will be checking in 2morrow. Thanks for your help tho, i have gotten a new start, and it should be completeted by next weekend (if i work like an hour a day)

Just so you all know, i am a 10th grader and am looking into a career in software engineering.

peace

KISS

(keep it simple stupid)

Share this post


Link to post
Share on other sites
Wow, LOWORBIT, you are good. I love the sites, thanks, it will help. To answer your comment, i am not knew to openGL, OR 3D. If i was, i wouldn''t have decided to create this object. It seems damn near impossible to me now. But i will still go on, if i figure it out then i will tell you all. Again thanks for all of your info!

Share this post


Link to post
Share on other sites
I don''t have much experience on OpenGL or on PCs period with this sort of thing, but I did get a rotating 4-d cube working on my TI-83. It might take a little work, but here''s what I did: I found all of the vertices, then figured that I should draw a line from one vertex to another if and only if there was only one coordinate different. Going by that, I got a list of all of the lines to draw to make a hypercube. ''Course, that''s just good for a wireframe model, but maybe you can work with it from there and make it more interesting.

CrystalFire

Share this post


Link to post
Share on other sites
Oluseyi:
Not sure what exactly you mean by unfolded.

Anyhow, a hypercube assumes four spatial coordinates. This is perfectly valid, and can even be useful. For something like a hypercube rotating, you could try to figure out what it would look like in 3D and emulate it, or you can set up a 4D model using 4D vectors, rotate them around some plane with a simple 4D rotation matrix, and then project into 3-space. Once you''ve projected into 3-space, OpenGL will handle the rest. Maybe some pseudo-code will help?

v1:=[1,1,1,1];
rot:=
[[cos(t), -sin(t), 0,0],
[sin(t), cos(t), 0, 0],
[ 0, 0, 1, 0],
[ 0, 0, 0, 1]];

To perform the rotation, just multiply the vector by the matrix (which in this case is a rotation matrix around the z-w plane):

v2:=v1*rot;

Now, we want to project this onto a three-space, just like opengl projects our 3D objects onto a two-space. I haven''t done this much, but it looks like openGL uses a projection matrix from 3 space to 2 space using a 4x4 matrix, so we probably want a 5x5 matrix. This means that we need to put a new weighting variable
into the v2, making it a 5-vector:

v2:=[v2[1], v2[2], v2[3], v2[4], 1];

Now, we can set up a 5x5 matrix to do the projection. I''m pretty sure that it goes like this:

proj:=
[[1, 0, 0, 0, 0],
[0, 1, 0, 0, 0],
[0, 0, 1, 0, 0],
[0, 0, 0, 1, 0],
[0, 0, 0, 1/d, 0]];

When we multiply the projection by the v2, we will get something that doesn''t have 1 as it''s last component, so we have to normalize it with respect to the weight:

v2:=v2*proj;
v2:=[v2[1]/v2[5], v2[2]/v2[5], v2[3]/v2[5], v2[4]/v2[5], 1];

By the properties of the projection matrix, the w term (second from last) is d, which is the solid that the hypercube is being projected to. So, we can just make a new vector, this one it 3-space, that only uses the first three components of the 5D vector. This works because every vector going through the matrix will have the same w value, so it can essentially be dropped. Thus:

v3:=[v2[1], v2[2], v2[3]];

and we can now do the normal openGL thing:

glVertex3fv(v3);

Do this for all your verts, and you''re set!

Share this post


Link to post
Share on other sites
quote:
Original post by tsuraan
Oluseyi:
Not sure what exactly you mean by unfolded.

We live in a 3D world, so we can''t actually fathom what 4 dimensions would look like. We therefore take a page from the translation of a cube to 2D space: if we unfold the sides of a cube, we obtain 6 squares (2d figures). By analogy, if we unfold a tesseract/hypercube, we obtain 8 cubes. We then try to fold them back into place, and the result is cubes that are at once inside and outside each other (hences the habitual representation of continuous "inter-rotation".)

Your other math and logic is accurate (it did take the fun out, though...)

Share this post


Link to post
Share on other sites
The book Visaul basic Graphics Programming has a chapter or two on higher dimension projections. I believe that it has all of the maths involved for projecting n dimensional figures into 2d screen space.

Spectacular book, good if for nothing other then the algorithms.

Z.

Share this post


Link to post
Share on other sites
WOW, i never excpected this much response to the question. I love the idea tsuraan, i dont think i ever would have thought of it. A few things tho...
CrystalFire im not sure if you will see this, but could i have that source for your ti 83, i have one too, and it would really help. Second, what do i say?!?!

glLoadIdentity();
glTranslatef(1.5f,0.0f,-7.0f); // Move Right And Into The Screen

glRotatef(rquad,1.0f,1.0f,1.0f); // Rotate The Cube On X, Y & Z

glBegin(GL_QUADS); // Start Drawing The Cube

what do i do with that, i mean, use your matrix v3 or v2. Or the prj, i just dont konw, maybe i am just alittle to inexpericed for this now.

Share this post


Link to post
Share on other sites
This hypercube thing is funny because if the inner cube was a face it would actually move and look at you from any direction you looked at it from........

Sort of like the haunted hause at Disneyland.....

WHO DID YOU EXPECT...?
MAYBE SATIN!!!

Share this post


Link to post
Share on other sites