We are about to switch to a new forum software. Until then we have removed the registration on this forum.
As you can see, its one polyhedron with five vertices.
Would you use triangle strip to construct it ? Or use single lines and group them in classes to tetrahedrons? In the end I like to highlight each of the single tetrahedrons eg via key commands.
Additionally I would like to experiment with shading to create depth effect. how would you do that? coloring the triangle planes black and white. Or can I place light sources?
Big thanks in advance for any help
I´m sure there are thousand ways. Please choose the simple one for me, doenst matter if its more code :)
Answers
Yep, exactly.
That's not really how it works. Which one is simple depends on you more than anything. We can tell you how we would do that, but that doesn't mean it's how you should do it.
The best thing you can do is break your problem down into smaller steps and take those steps on one at a time. For example, can you create a simple version of one of these shapes? Start with a basic triangle.
Then if you get stuck, you can post a MCVE along with a more specific technical question. Good luck.
is this 3D?
because somehow the gray lines seem to be crossing the color lines. or the gray lines define a pyramid which intersects with the colored main part which is strange
https://www.processing.org/reference/vertex_.html
the picture is a screenshot from that video (5:43min)
how this 4D to 3D abstractions shall work - i´have no idea. 4th dimension to me is time - like the tetrahedron in movement.
but it seems to me that I could make five vertices in 3D space, connect them and the result is a polyhedron which contains 5 tetrahedron and consequently multiple depth perspectives.
Beeing able to choose between depth perspectives - this is what I´m interesting in. Choosing the combination of planes to open up a space. Would it work with this approach?
when i've done this i've defined my own class to hold 4d values, like a pvector but one louder. you also have to write 4d rotation code (think of a 3d rotation matrix, only 4d, and instead of 3 axes you can rotate around you have 6 planes you can rotate around) and finally a 4d perspective transform (again, quite a simple extension of the 3d equiv).
(i'd post some examples but mine are actually 5d, and quite old)
as for creating the shape, you'd have an array of 5 of your 4d points and an array of 10(?) pairs of vertices, which define which lines connect which vertices (and maybe a 4d-equivalent of an array of faces, which define the individual tetrahedra)
@TillFly: The 4th dimension is time in the sense of Albert Einstein (https://en.wikipedia.org/wiki/Spacetime) but in your context, it's not time.
It's just an additional space dimension, like when we go from point to line, to plane, to cube and then to a 4th dimension. You could go on to 5th, 6th and so forth.
koogs has described the best way to do it.
But here is a simple triangle in 3D, that you can rotate with the mouse (PeasyCam)
so then i have to go after this thank you very much!
see
https://en.wikipedia.org/wiki/Four-dimensional_space
https://en.wikipedia.org/wiki/Euclidean_geometry
https://en.wikipedia.org/wiki/Tesseract
https://en.wikipedia.org/wiki/Hypersphere
If for any given rotation you are creating a set of 3D tetrahedra as a projection into 3D space then you can shade them, texture them, or light them just like any other 3D object in Processing. By the time you know where they go, they aren't special -- they are just up to five 3D objects (each consisting of four 2D faces) -- these objects just that happen to share sides.
If you are rendering a 5-cell, that means that for any given rotation of your 4d points list, you are then you are always going to render a Tetrahedron 5 times, and always with fixed 3D projections of points from your 4D point array. Whatever output you get, you can shade and light. Since there are always only 5 Tetrahedrons objects in your FiveCell object, that should make shading [1] or [3] fairly simple.
Related:
thanks a lot for that great input!
I tried it this way, but three coordinates with vertex() dont work with P3D of the size() object.
@koogs How does it work to assign number with lists like this to a 4D grid? (dont pay attention to the number pls)
this is a 2d vertex with a texture applied, not a 4d vertex
and that is a [][4] array, not a 4d array. but that's all you need - ditch two of the []s in the definition.
hm.. sorry, I dont understand how this shall work with a 2D array. how can I iterate of the lists of myArray?
this is where I am right now:
maybe call it something other than myArray and things would be clearer. an array of what? looks like a vertex array. so call it that. now you have an array of vertices and each element has 4 values, one for each dimension.
so you create an array of vertices with values and then set them all to 0? why?
(and you do this 60 times a second until you stop the code. nothing is drawn.)
i would have written in class PVector4D with x,y,z,z2 but never mind
your array is ok as well
in draw start by saying ellipse( myArray[......
you need a way to project the 4 coordinates of one point to the 3D realm then and display the array using pushMatrix(); translate (x,y,z); sphere (4); popMatrix();
because I dont know how to continue -.-
why an ellipse? shall there be an ellipse instead of a Point?
how can I have an ellipse with four coordinates?
just to make sure that I understood the next tasks:
I just would like to print the VertexArray[i][j] values and the monitor says: "ArrayIndexOutOfBoundsException:4"
I guess the i++ is counting further then the size of the array, but it should stop when the "i < cols-condition" is not fullfilled anymore..? Why is that happening?
your array is [5][4], 5 rows of 4 values each. rows should be the outer loop.
it's easier with classes, you'll just confuse yourself with a 2d array
sorry just to understand this: how to put "row" out of the loop?.. I need that number to iterate?..
thanks for the code with the classes. I will continue with that.
For 4D rotation and projection see
https://www.uni-koblenz.de/~cg/Studienarbeiten/4d_mosig.pdf
Projection: either just ignore w or follow the matrix formula for distance s
see page 15
moving rows to the OUTER loop
aah sorry koogs, I´m a noob here...
trouble again: when I want to compile it like the code below debug log says: "unexpected token: (" - in the constructor line.
when hovering over the constructors it says "=" missing. But the syntax of the constructors in comparison with the reference is correct where is the mistake?
Hello Mr. GoToLoop,
thanks a lot for your investigation! I´m having a hard time to understand this :/ I wrote some questions (marked with ??) inline the code. would be awwweseome if you could comment on those.
i'm guessing the get() just allows you access to the values within the point. i'd skip it and just use point.x etc instead. ditto the set().
line 44 is the constructor. that's what's being run when you call new Point4() and it just stores the values passed in as parameters into the variables belonging to the instance.