4th Demension...

Started by
16 comments, last by DarkHunter 22 years, 5 months ago
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!
Advertisement
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
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!
well, I guess I sucked the fun right out of that one...
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...)
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.
______________"Evil is Loud"
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.
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!!!
WHO DID YOU EXPECT...?MAYBE SATIN!!!

This topic is closed to new replies.

Advertisement