Drawing an undirected graph in inkscape - inkscape

I need to draw some undirected graphs with different coloured vertices. Previously I have been doing this the tedious way, by drawing every vertex as a circle and every edge as a straight line. Is there a way that I can do this easily by using the Bezier curve function? I have tried to do this, but can't work out how to add vertices to my lines!

I'm guessing you want to create un-directed graphs with curved edges (since you mention Bezier curves).
I find that the easiest way to draw freestyle graphs is to lay down your vertices as circles (copy & paste for consistent size) and then use the "draw freehand lines" option (pencil icon) to connect the dots. Then you send the circles to the front layer, so the lines look like they start and end at the edges of your circles. If you really want to use Bezier curves instead of free hand, then the method applies just the same. Here's a sample I created using the first method.
Hope this helps.

So this answer uses an external tool as part of the process, but the end result is still a (good looking) graph inside of inkscape. So for anyone who wants relatively hassle free graphs inside inkscape (or other software) who stumbles across this question, hopefully this will be useful.
There is a (free) tool called the yEd Graph Editor which allows for simple creation of graphs, and after creating a graph you can copy them to the system clipboard (right-click menu) and paste them into inkscape. It requires installing an additional piece of software, but the process can be much faster than creating them manually in inkscape as yEd makes it easy to deal with things like layout, node style, edge style and similar.
This process works with other image software as well, both those that work in bitmap and vector graphics and yEd works with a wide range of graph types.

Related

Drawing area graph in directX

I have an MFC application to draw graph using DirectX. Now I have to add the feature to draw the area graph in DirectX.
Now my application draws like this..
I want to include the feature to my graph to look like this..
here I have to fill the graph area with some color.
I have tried DrawPrimitive(). but this could be used to draw the Triangle, rectangle. but in my application I would like to draw graph with random data points.
Is it possible to achieve in DirectX..?
Kindly someone provide your suggestions.
If u need 2d graph's alone Direct2D is a great option,But if you insist on going to 3D for greater animation and illustrative purposes you can uses OpenGL.There are plenty of custom controls for graph illustration purposes based on OpenGL.
For eg:
http://www.codeproject.com/Articles/4346/D-Graph-ActiveX-Control
Opengl has greater flexibility and can serve your needs better since it is of open source.
hope this helps and Good Luck

Visualize 3D Bar Graph in C++

I have some 3D data (xyz coordinates) that I am trying to represent as a 3D bar graph. What is the best way to visualize this in C++? I would also like to display different colors based on the z value. Any information about this would be great.
Thanks in advance.
I imagine you were hoping for a turn-key solution to your problem, but, although I have seen a lot of 3D bar charts over the years, I don't have a library which I can point to and say "just use this." I once watched as researchers virtually walked around on top of a huge 3D bar chart in Second Life, discussing the depth of data exploration only immersion can offer.
The problem is that you need a dynamic view, with mouse input as a minimum. There are some libraries for 3D graphing, but those are for visualizing surfaces, which isn't really what you're after. Here's one with an ActiveX control interface for starters.
So now I'm thinking about graphical APIs, such as OpenGL and DirectX, where you could just draw the geometry yourself. But I'm not sure you know anything about graphics programming, and so getting a single triangle on screen will be a task, let alone 2*5*w*h triangles. No offense - its an actual GD ordeal.
So short of explaining how to do that in any reasonable way, now I'm wondering if I can simply sidestep the issue. You could use any number of graphing libraries to draw a matrix of charts, one for each slice in the grid. Or a 2D color heat map, where the color matches the Z value, as you suggested.
But that's not helpful, because you wanted a 3D bar chart. So maybe I can talk you out of it? While its been shown that people prefer 3D bar charts, they don't perform as well using them, compared to 2D representations. And if you want a 3D representation to be effective, you may need to employ stereo 3D or linked physical models.
I hope my ramblings have at least been amusing.
Not free, but would this fit the bill? https://www.qt.io/blog/2013/11/07/qt-data-visualization-technology-preview-and-charts-1-3-1-release
Maybe: Use R, and a C++ binding library, like Rcpp.
Or perhaps: PLplot.

deformation of SVG file. Bezier Curves?

I have an SVG file.This file shows the outline of cartoon character(2D character).
My question is, can I make a program that It allows the user to interact with the outline and deform it.
An example is, to pull the outline of character's arm, with the mouse,and the arm gets bigger.
I suppose that Bezier Curves and Elliptical Arcs is a solution.I also wonder if i use OPENGL, I might be more flexible to do that.
The interaction aspect you'll need to deal with yourself. There is a recent OpenGL extension, NV_path_rendering which makes accurate, hardware-accelerated rendering of SVG and other vector formats pretty simple. The SDK includes at least one example where interaction with control points is shown, which might make a good starting place for you. Obviously, this would require you/the end user to have a GPU which supports the extension. Here's a video of the developer explaining the extension and what it can do.
I also wonder if i use OPENGL, I might be more flexible to do that.
OpenGL will not make things easier in any way. OpenGL is a drawing API, not some kind of magic scene and geometry manager. All it gives you are points, lines and triangles and methods to define how those are to be drawn to a framebuffer.
Interaction with the user lies completely outside the scope of OpenGL.
iscriptdesign allows you to create interactive graphics, but you need to program/script those yourself.

Creating the links of a chain in OpenGL

I am working on a project where I have to create a chain with 12 links in it. I want to create the chain out of two curved segments for the top and bottom of the link ad two cylinders for the straight segments, I intend to use a display list to create one link and then display it over and over after applying some rotation transformations. My question is how can I construct the curved sections?
One idea was to use gluPartialDisk(); swept thru 180 degrees to construct the top and bottom portions. is there a more efficient way of doing this?
PS: Forgot to mention that this was to be in 3D, I guess gluPartialDisk() will not work in this case. I want to use basic OpenGL shapes to create this rather than using 3D modeler, this way I will be able to learn more about OpenGL.
Assuming you want to use display lists, gluPartialDisk() is probably efficient enough (and it's not worth the effort to implement it yourself).
However, there are methods that are even faster than using display lists themselves. I would highly suggest using vertex arrays or vertex buffer objects.

Best way to render hand-drawn figures

I guess I'll illustrate with an example:
In this game you are able to draw 2D shapes using the mouse and what you draw is rendered to the screen in real-time. I want to know what the best ways are to render this type of drawing using hardware acceleration (OpenGL). I had two ideas:
Create a screen-size texture when drawing is started, update this when drawing, and blit this to the screen
Create a series of line segments to represent the drawing, and render these using either lines or thin polygons
Are there any other ideas? Which of these methods is likely to be best/most efficient/easiest? Any suggestions are welcome.
I love crayon physics (music gets me every time). Great game!
But back to the point... He has created brush sprites that follow your mouse position. He's created a few brushes that account for a little variation. Once the mouse goes down, I imagine he is adding these sprites to a data structure and sending that structure through his drawing and collision functions to loop through. Thus popping out the real-time effect. He is using Simple DirectMedia Layer library, which I give two thumbs up.
I'm pretty sure the second idea is the way to go.
First option if the player draws pure freehand (rather than lines), and what they draw doesn't need to be animated.
Second option if it is animated or is primarily lines. If you do choose this, it seems like you'd need to draw thin polygons rather than regular lines to get any kind of interesting look (as in the crayon example).