How do you create and render a 3D Fractal? - java

So I've been assigned a recursive art project for my AP CS class and have a bunch of spare time, so I've decided to try something a little bit more ambitious.
My plan is to create a 3D fractal, either rendered and shaded in a visualization with GL, or represented via spatially mapping the respective equations' outputs to points on a cube and drawing those. If this explanation seems unclear, please check out the links at the bottom for images. Now, I don't need the fractal to be able to be modified in-program. I just need it to render a single BufferedImage, which I'll be putting directly on a JFrame.
My experience in Java, as far as this project goes, is a bit limited. I've drawn Mandelbrot and Julia set fractals before, but I have little to no experience drawing/rendering objects in 3D in Java. This is all stuff I can look up and figure out myself though, so no worries here.
Thus, the question: How does one map a fractal that should be in the 2nd dimension (e.g. log(no. of subdivided entities)*log(side length of subdivision) = 2) to the 3rd dimension (e.g. log(no. of subdivided entities)*log(side length of subdivision) = 3)? I'm lost trying to mathematically work this out, and I believe there is a more organized approach to go about this circumventing a lot of the math that already exists.
Also, if you are aware of a structured approach to render a 2D fractal, as drawn by a formula, and render it in 3D, provided the respective formula is provided (power is raised), please let me know. I've heard of Ray Tracers, no idea what they are, a brief summary would be cool.
Here are links with pictures of the result I want to obtain:
http://2008.sub.blue/assets/0000/4575/power8_large.jpg
https://www.youtube.com/watch?v=rK8jhCVlCtU

It looks like the image is an example of a Mandelbulb. The is a similar iteration formula to the Mandlebrot set but using 3D points and a novel idea of what raising a 3D point to a power means.

Related

Turn a set of 3d coordinates into polygonal "landscape" in Java

I'm working on a visualization project. From the data I have calculated the X, Y, and Z coordinates for a large set of points. Using Processing it was very simple to draw this out with lines and dots.
From the top it looks like this:
And from a side angle you can see how it occupies 3D space
The part I'm struggling with is turning this into polygons. I need the end result to be something I can export as a .obj file, and then later open in Blender or similar 3D modelling programs.
The two main issues are that these points are not on a grid, but are instead organized in a circle based on radian angles, and that the triangle structure isn't all that simple.
I tried drawing out my own polygons (it's kinda sorta working), but I'm getting to the point where the maths are getting a bit too complex to handle and my code is bloated with arrays, if statements, and for loops...
Surely there must be a better way? Are there any plugins maybe that would help me with this task? Or some techniques I should take a look at?
Processing has screenX() and screenY() functions that take a 3D point and return a 2D point. That sounds like pretty much exactly what you're looking for. Please see the reference for more info.

Using Java & BoofCV to detect shapes in an image file

I've not found anything here or on google. I'm looking for a way to identify shapes (circle, square, triangle and various other shapes) from a image file. Some examples:
You get the general idea. Not sure if BoofCV is the best choice here but it looks like it should be straightforward enough to use, but again I know nothing about it. I've looked at some of the examples and I though before I get in over my head (which is not hard to do some days), I thought I would ask if there is any info out there.
I'm taking a class on Knowledge Based AI solving Ravens Progressive Matrix problems and the final assignment will use strictly visual based images instead of the text files with attributes. We are not being graded on the visual since we only have a few weeks to work on this section of the project and we are encouraged to share this information. SOF has always been my go to source for information and I'm hoping someone out there might have some ideas on where to start with this...
Essentially what I want to do is detect the shapes (?? convert them into 2D geometry) and then make some assumptions about attributes such as size, fill, placement etc, create a text file with these attributes and then using that, send it through my existing code based that I wrote for my other projects to solve the problems.
Any suggestions????
There are a lot of ways you can do it. One way is to find the contour of the shape then fit a polygon to it or a oval. If you git a polygon to it and there are 4 sides with almost equal length then its a square. The contour can be found with binary blobs (my recommendation for the above images) or canny edge.
http://boofcv.org/index.php?title=Example_Fit_Polygon
http://boofcv.org/index.php?title=Example_Fit_Ellipse

Custom 3D Rendering

So I've been prodding ever so diligently at the internet as of late and have come across some interesting games. The basic example is Minecraft4k. It was made for the Java4k contest a few years back, but what I am really interested in is how the rendering was done. There are a lot of games like this made every year, but I really can't find much on how the creators went about synthesizing 3D worlds, let alone with minimal code.
The basics that would have be implemented would be polygon filling, z-ordering, and some sort of "fog" in order to prevent too much landscape from being drawn (optional, really). I've read up on the Scan line filling algorithm and have a working example but I have no idea how to get any form of z-buffering working. So the question is, does anyone have any experience with this sort of custom 3D rendering work? If so, any tips/pointers/resources you can point me to?
I know this is a bit of a shallow and perhaps inadequate question, but I figured I would try on here. Thanks in advance!
Wikipedia is a good start point (though it is bad for me to post a link) and explains about different techniques.
I developed a 3D software renderer for dots (the simplest 3D renderer ever ;)) and the z-buffering consists of sorting an array of rendered elements according to the Z coordinate, which in turns depend on the projection you are using, either orthographic, isometric, etc. (see another Wikipedia article about projections). In the simplest projection, you simply ignore the Z coordinate when drawing object, but take it into account during rotations (as it has an impact on X and Y).

How to know if a point is inside a complex 3D shape (.ply file)

I'm working on a Java project witch is really killing me. After several days of researching on different forums, looking for what I really need, I come to ask your help.
My data :
A .ply file (containing a 3D shape made of a lot of triangles)
A point (3D coordinates)
I would like to know if this point is contained inside the complex 3D shape.
I have split this problem in 2 smaller problems :
How can I represent the complex 3D shape in memory? (I found several libraries, but it seems really complex for the task I want to do : Java3D, JBullet, JME3...) I do not want my java application to show the object for now.
How can I know if this point is inside the 3D shape or not? (I thought to make a 3D vector starting from the point and to count the number of intersections with the shape, but I don't see how to do and witch library can I use?)
Maybe there are easier ways to do it, that's also why I come to you.
I am really stuck now and I would like if this is possible without writing customs libraries...
(Sorry for my writing, I'm not English ^^)
Thanks for helping me.
Here is one approach. Not the best or the fastest, but once you have something working, it will be easier to improve upon.
How can I represent the complex 3D shape in memory?
Implement a quick and dirty PLY file format parser. Here is the PLY format spec. Load the data up and store it internally: an array for each X, Y, and Z. This is all just plain Java.
How can I know if this point is inside the 3D shape or not?
Define a line based on your point and some other arbitrary point. For each polygon, determine where it intersects the plane (some help) and if the intersection point is inside or outside the polygon (some help). As you suggested, then count the number of intersections to determine if the point is inside or outside your 3d shape.

How to create 3D Tag Cloud in Java

I need a suggestion/idea how to create a 3D Tag Cloud in Java (Swing)
(exactly like shown here: http://www.adesblog.com/2008/08/27/wp-cumulus-plugin/)
, could you help, please?
I'd go either with Swing and Java2D or OpenGL (JOGL).
I used OpenGL few times and drawing text is easy using JOGL's extenstions (TextRenderer).
If you choose Swing, than the hard part will be implementation of a 3D transformation. You'd have to write some sort of particle system. The particles would have to reside on a 3D sphere. You personally would be responsible of doing any 3D transformation, but using orthogonal projection that would be trivial. So it's a nice exercise - what You need is here: Wiki's spherical coord sys and here 3d to 2d projection.
After You made all of the transformation only drawing is left. And Java2D and Swing have very convenient API for this. It would boil down to pick font size and draw text at given coordinates. Custom JPanel with overriden paintComponent method would be enough to start and finish.
As for the second choice the hardest part is OpenGL API itself. It's procedural so if You're familiar mostly with Java You would have hard time using non-OO stuff. It can get used to and, to be honest, can be quite rewarding since You can do a lot with it. If you picked OpenGL than you would get all the 3D transformations for free, but still have to transform from spherical coordinate system to cartesian by yourself (first wiki article still helpful). After that it's just a matter of using some text drawing class, such as TextRenderer that comes with JOGL distribution.
So OpenGL helps You with view projection calculations and is hardware accelerated. The Java2D would require more math to use, but in my opinion, this approach seems a bit easier. Oh, and by the way - the Java2D tries to use any graphic acceleration there is (OpenGL or DirectDraw) internally. So You are shielded from certain low-level problems.
For both options You need also to bind mouse coordinates s to rotational speed of sphere. Whether it's Java2D or OpenGL the code will look very similar. Just map mouse coordinates related to the center of panel to some speed vector. At the drawing time You could use the vector to rotate the sphere accordingly.
And one more thing: if You would want to try OpenGL I'd recommend: Processing language created on MIT especially for rich graphic applets. Their 3D API, not so coincidentally, is almost the same as OpenGL, but without much of the cruft. So if You want the quickest prototype that's the best bet. Consult this discussion thread for actual example. Note: Processing is written in Java.
That's not really 3D. There are no perspective transformations or mapping the text on some 3D shape (such as, say, a sphere). What you have is a bunch of strings where each string has an associated depth (or Z order). Strings "closer" to you are painted with a stronger shade of gray and larger font size.
The motion of each string as you move the mouse is indeed a 3D shape which looks like a slanted circle around a fixed center - with the slant depending on where the mouse cursor is. That's simple math - if you figure it for one string, you figure it out for all. And then the last piece would be to scatter the strings so that they don't overlap too much, and give each one the initial weight based on their frequency.
That's what most of the code is doing. So you need to either do the math, or translate the ActionScript to Java2D blindly. And no, there is no need for JOGL.
Why don't you just download the source code, and have a look? Even if you can't write PHP, it should still be possible to read it and figure out how the algorithm works.

Categories

Resources