Basically, I'm looking for something like this awesome research project: Gmap, which was referenced in this related SO question.
It's a rather novel data visualization that combines a network graph with an imaginary set of regions that looks like a map. Basically, the map-ification helps humans comprehend the enormous data set better.
Cool, huh? GMap doesn't appear to be open source, though I plan to contact the authors.
I already know how to create a network graph with a force-directed layout (currently using Prefuse/Flare), so an answer could be a way to layer a mapping algorithm on top of an existing graph. I'm also not concerned about the client-side at all right now - this would be a backend process, and I am flexible about technology stack and data output at this stage.
There's also this paper that describes the algorithm backing GMap. If you have heard of Voronoi diagrams (which rock, but make my head hurt), this paper is for you. I quit after Calc 1, though, so I'm hoping to avoid remembering what sigmas and epsilons are.
As a start, could you do a simple closest point sort of an algorithm? So it looks something like this: You have your force directed layout and have computed some sort of bounding box. Now you want to render it. Adjust your bounding box to line up to the origin and then as you calculate the color of each pixel, find it's closest point. This should generate some semblance of regions and should be quite simple to try out. Of course, it isn't going to be as pretty as GMap, but maybe a start? The runtime would be awful, but... I don't know about you but computing boundary lines directly sounds a lot harder to me.
Related
I'm picturing a typical random polygon hillside with ridges that come together into bigger ridges as you ascend and canyons that come together into bigger canyons as you descend.
The way you normally make something like this is to start with the top of the whole mountain and iterate until you have enough detail in the area you're interested in and then stop.
OK, suppose there is no absolute mountain top; it just keeps going; and I want to generate the neighboring chunk before I get to it so it matches up with what is already there.
After thinking about it for a while I think this is probably either impossible or involves a kind of math I haven't even heard of. On the other hand it -seems- like it 'should' be possible, (with extra information stored per-vertex)?
Maybe try doing it in 2D first and see what you can come up with.
It looks possible in 2D, in 3d it would work too but not with a real mountain with a top, more with an endless slope that does not converge to a point.
What you want to do is actually reversing the gravity rules in some sense.
Not sure if this is really an answer, but the question is quite vague too :)
Goodmorning everybody,
I searched in the web for this problem for something like an hour an nobody seemed to have my same difficulty, so here I am. I'll explain you my problem: I have four states (but in future they can become much more the four) A, B, C and D between which a particle can do transitions. Suppose I know exactly how many times the particle undergoes the A->B, B->C, C->D, A->C (... and so on) transitions. I want to represent my states as dots on a circle and the transitions as arrows between states, which are wider (the arrows, not the dots!) proportionally to the number of transitions. I hope I made myself clear. Is this possible on Gnuplot 4.6? Otherwise: do you know other programs able to do that? Because I saw maps like this before, but sincerly I don't even know how to search for them!!
Thank you very much for your help.
A much more suitable tool for your problem would be Graphviz. You can use the Graphviz “DOT” language to express your transition map directly, and then use the Graphviz tools to perform various types of automated layout (including circular ones) and to produce image files showing the nodes and edges in the graph. If none of the automated layouts are what you want, you can compute them yourself and set the positions explicitly, and still use graphviz's renderer.
Ok, here is the thing. Recently i decided i wanted to understand how Random map generation works. I found some papers and some arguments. The most interesting one was "Diamond Square algorithm" and "Midpoint Displacement". I still have to try to apply those to a software, but other than that, i ran into this site: http://www-cs-students.stanford.edu/~amitp/game-programming/polygon-map-generation/
As you can see, the idea is to use polygons. But i have no idea how to apply that a Tile-Based map, not even how to create those polygons using the tools i have (c++ and sdl). I am assuming there is no way to do it ( please correct me if i am wrong.) But if i am not, how does a non-tile map works, and how are these polygons generated?
This answer will not give you directly the answers you're looking for, but hopefully will get you close enough!
The Problem
I think what blocks you is how to represent the data. You're probably used to a 2D grid that simply represent the type of each tile. As you know, this is fine to handle a tile-based map, but doesn't properly allow you to model worlds where tiles are of a different shape.
Graphs
What I suggest to you, is to see the problem a bit differently. A grid is nothing more than a graph (more info) with nodes that have 4 (or 8 if you allow diagonals) implicit neighbor nodes. So first, what I would do if I was you, would be to move from your strict standard 2D grid to a more "loose" graph, where each node has a position, a position, a list of neighbors (in most cases you'll have corners with 2 neighbors, borders with 3 and "middle" tiles with 4) and finally a rendering component which simply draws your tile on screen at the given position. Once this is done, you should be able to have the exact same results on screen that you currently have with your "2D Tile-Based" engine by simply calling the rendering component with each node who's bounding box (didn't touch it in what you should add to your node, but I'll get back to this later) intersects with the camera's frustum (in a 2D world, it would most likely if the position +/- the size intersects the RECT currently being drawn).
Search
The more generic approach will also help you doing stuff like pathfinding with generic algorithms that explore nodes until they find a valid path (see A* or Dijkstra). Even if you decided to stick to a good old 2D Tile Map game, these techniques would still be useful!
Yeah but I want Polygons
I hear you! So, if you want polygons, basically all you need to do, is add to your nodes a list of vertices and the appropriate data that you might need to render your polygons (either vertex color, textures and U/V maps, etc...) and update your rendering component to do the appropriate OpenGL (this for example should help) calls to draw your nodes. Once again, the first step to iteratively upgrade your 2D Tile Engine to a polygon map engine would be to, for each tile in your map, give each of your nodes two triangles, a texture resource (the tile), and U/V mappings (0,0 - 0,1 - 1,0 and 1,1). Once again, when this step is done, you should have a "generic" polygon based tile map engine. The creation of most of this data can be created procedurally by calculating coordinates based on tile position, tile size, etc...
Convex Polygons
If you decide that you ever might need NPCs to navigate on your map or want to allow your player to navigate by clicking the map, I would suggest that you always use convex polygons (the triangle being the simplest for of a convex polygon). This allows your code that assume that two different positions on the same polygon can be navigated to in straight line.
Complex Maps
Based on the link you provided, you want to have rather complex maps. In this case, the author used Voronoi Diagrams to generate the polygons of the map. There are already solutions to do triangulation like that, but you might also want to use other techniques that are easier to work with if you're just switching to 3D like this one for example. Once you have interesting results, you should consider implementing serialization to save/open your map data from the game. If you want to create an editor, be aware that it might be a lot of work but can be worth it if you want people to help you creating maps or to add elements to the maps (like geometry that's not part of the terrain).
I went all over the place with this answer, but hopefully it helps!
Just iterate over all the tiles, and do a hit-test from the centre of the tile to the polys. Turn the type of the tile into the type of the polygon. Did you need more than that?
EDIT: Sorry, I realize that probably isn't helpful. Playing with procedural algorithms can be fun and profitable. Start with a loop that iterates over all tiles and chooses randomly whether or not the tile is occupied. Then, iterate over them again and choose whether it is occupied or its neighbour is.
Also, check out the source code for this: http://dustinfreeman.org/toys/wall7-dustin.html
What I'm trying to achieve:
Have a look at the following image from this paper
It's taking a road graph that is likely represented as segments/junctions, giving the lines width (call it what you like, sweeping, thickening) and then generating triangulated geometry for the roads.
Why I am asking this question:
This operation seems to be a fairly standard thing to do, but I can't any papers that directly deal with how to do it. Most GIS / procedural city generation papers focus on the generation of the road graph itself (e.g. creating interesting topologies), but the step involving taking the graph data and generating triangle meshes / UVs is always glossed over.
Here's a really nice video of complex road intersections with nice texturing and good-looking junctions. This is the level of quality I'd eventually like to achieve, but an incremental step towards this would be more than acceptable to me. Here's another video showing interactive road graph creation with a 3d visualisation.
There is a paper to go with that video but nothing is said about the triangulation strategy :(
I have my own approach to try that's too long-winded to detail here, but I'd much rather implement an existing solution / algorithm if one exists, as it'll be better than anything I cook up in the next few weeks.
Can anyone point me in the right direction?
Thanks.
What you are seeking is the offset polygon for each of the regions bounded by roads. If all those regions are convex, this is an easy computation. If some are nonconvex, then it is more difficult, but still well-studied. You can find links at Wikipedia under straight skeleton, or here on StackOverflow under "An algorithm for inflating/deflating (offsetting, buffering) polygons."
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
I'm interested in creating poster-sized images that contain repeating patterns, similar to the two (public domain) images below, the Flower of Life and a Penrose tiling:
My questions:
How do people usually create images like these on a computer? I'm hoping the answer isn't, "Open Adobe Illustrator and guess at intersection points," since such points can be defined mathematically. But I also imagine that not everyone with an interest in geometric patterns is also familiar with programming.
What is the best environment for creating such images? In particular, what's the best way to get high-resolution images out of Java, Python, Processing, etc? Or, is Mathematica the best tool?
Actually calculating the points and doing the math isn't the hard part, in my mind (at least, it's not the focus of this question). I'm interested in the best way to get a high-quality visual product out of a program.
The best way to create images like these is to learn to write PostScript. It's a clean language, easy to learn, and quite powerful once you know it well.
Bill Casselman's manuals are by far the best reference for high quality mathematical illustration.
Use a vector image format like SVG. This will scale perfectly to any resolution.
Inkscape is a great tool for creating these.
Once you have a vector image format, there are many options for using it in programming languages, depending on your language of choice.
For example -
.NET - SvgNet
ActionScript - svgweb
C++ - LeadTools
XAML for WPF/Silverlight - ViewerSVG (Converts SVG to XAML)
I don't know how those images were created, I would guess they were scanned from a book, but, in my work with fractals, I tend to start with just using the <canvas> tag, mainly so that I can change the size of the element and see it drawn more iterations, so I can get the highest resolution.
That is the problem with something like SVG is that you would need to pick a resolution and then create it, and it will scale well up and down, but if you developed it at one resolution, then you go to a higher resolution to demo, you may see more gaps than you would like.
If you want to just do it and save it as a static image then any GUI will work, as you are saving a GIF at that point, but if you want it, for example, on a web page, and have it look as good as it can on that browser then you may want to look at using javascript.
The math part isn't hard, and so drawing the image is fairly easy, once you derive the recursive algorithm that is needed. I tend to go to the next iteration until the size is below a threshold, for example, a radius of < 3, then it exits.
Well, #2 is going to be kind of a holy war so I'll address #1. :)
The key to images of this nature is recursion. Basically they are the same image repeated over and over in a controlled way to get an intersting result. Take the flower of life for example. You repeat the center petal six times (the method to do the petals is up to you). Then you create six more flowers using the petals tip as the center and overlapping one of the petals. You then recursively move outward. After a few "rounds" you stop and draw the containing circle. Basically the recusion simulates the stamp, move and rotate that would be required if you were doing it by hand.
When I have played around with these kinds of things I have always found that experimentation is the best way to get cool new things. Of course that could be just my lack of imagination. :)
I know I am not very math heavy in this answer but that is up to you and experimentation. Just remember that COS and SIN are your friends and there are 360 degrees in a cricle (or 2pi radians depending on your math package).
EDIT: Adding some math for the "Flower"
Starting with a center of (Xo, Yo) and a flower radius of r...
The tips of the petals (P0, P1, etc) are determined by...
X = Xo + (sin((n * pi)/3 + (pi / 6)) * r)
Y = Yo - (cos((n * pi)/3 + (pi / 6)) * r)
where n is the petal number (0..5)
Once you compute a petal tip, just draw the petal and then start a new flower at the tip. You would also set a bounding circle so that any point outside that circle would not be drawn.
I would try to create a PDF with iText in Java. PDF supports vector graphics, so it should scale without problems. I don't know how well iText scales w.r.t. performance when you have a really big number of graphic elements.
A1. You might want to look at turtle-graphics, l-systems, iterated function systems, space filling curves, and probably a lot of other approaches I'm not familiar with or haven't thought of yet.
A2. You can program any of these with any of the languages you suggest. I like Mathematica, but I know that not everyone has a copy of it and I have a copy 'cos I work in number-crunching and get to play with it for making pretty pictures. But Processing, which is free, was designed to be artist-friendly and might be a better starting point for you. Both Mathematica and Processing do the graphics right there and then, no calls to external libraries (or worrying which ones to use).
And, while I agree with everyone who says that vectors are the way to go, don't forget that the final productions step, onto paper or screen, is rendering so give some thought to how that will be done. This might, for example, lead you to Postscript or PDF for an output format.
Have fun
Mark
Well, I used to draw flowers of life with a compass, back then in junior school ... very simple actually ... but I don't think that's the answer you're looking for.
Basically it consists of drawing a circle of the same radius, from every point, until you encounter the big circle (limit).