How to produce high-quality renders of space curves and surfaces from ASCII input (ie gnuplot input) - graphics

Usually in plotting software, space curves are represented as a matte line. However, this is not always sufficient to visualize them. This is more prominent in cases of curves on surfaces where the surface is either minimally shaded or not at all (ie matte).
A different approach is to plot the space curves as thin shaded cylinders, where the lighting effects on the cylinder help visualise the curvature/torsion of the curve.
I want to produce such renders of curves on surfaces. What is the easiest way to take a similar ASCII format to gnuplot and produce the more complex renders I describe above?
I am looking for some free rendering software, which accepts a series of interpolation points and can generate something like the above

Related

What is the Proper way to Draw an Annulus (Wide Circle) using Bresenham's Algorithm?

Using only a box function, what is the proper way to draw an annulus (wide circle) using Bresenham's algorithm? I assume that consecutive parallel lines could be drawn, but that using an angled line instead of a point would be more feasible, but also involve trigonometry.
I am using Python, but examples in any language appreciated.
You cannot fill all ring points with radial lines, because for R2=2*R1 outer circumference contains twice as much points in it's raster representations, and there will be empty places near outer circle.
Graphics engines (DirectX, OpenGL and so on) often use triangle fans to fill the circles, ellipses, rings.

Creating a surface from a path of 3D cubic bezier curves

I have a list of cubic bezier curves in 3D, such that the curves are connected to each other and closes a cycle.
I am looking for a way to create a surface from the bezier curves. Eventually i want to triangulate the surface and present it in a graphic application.
Is there an algorithm for surfacing a closed path of cubic bezier segments?
It looks like you only know part of the details of the surface (given by the Bezier curves) and you've to extrapolate the surface out of it. As a simple example I'm imagining a bunch of circles in 3D with the center and radius that will be reconstructed into a sphere.
If this is the case you can use level sets. With level sets, you define a bunch of input parameters that defines the force exerted by the external factors on your surface and the 'tension' of the surface.
Crudely put, level sets define the behaviour of surface as they expand(or contract ) over time. As it expands it tries to maintain it's smoothness while meeting other boundary conditions - like 'sticking' to the circles in this case. So if you want a sphere from bunch of circles, the circles will exert a great force, while the surface will also be very tense.
Physbam has an open source implementation of level sets.
CGAL and PCL also provide a host of methods that generate surfaces from things such as points sets and implicit surface. You may be able to adapt one of them for your use.
You can look into the algorithms they use if you want to implement one on your own. I think at least one of them use the Poisson Surface Reconstruction algorithm.

Contour detection on sketched lines

I have a set of curves as input, represented as a list op point coordinates.
I want to merge them into one, more or less beautiful, curve.
Any idea how to do that?
UPDATE:
It should work on a single curve like that:
The most important aspect, to make the result curve nice, and supress the draw errors.
You have zero noise in your image, that is there is no salt-and-pepper artefacts just a somewhat curvy lines. The easiest way to merge them if there are not that many gaps is to use blur or morphological expansion to connect parts together (both may distort a shape just a bit) and then use findContour().
If there are larger gaps you have to use convex Hull on convex parts and then on concave residuals. Snake or active contour algorithm is probably an overkill in this situation.

How to describe fat curve (curved line of variable thickness)?

I know how to describe curved line of constant thickness (with Bezier or similar models).
Are there any common models of curved line with variable thickness?
I am imagining some similar things like in Bezier. For example, each node can contain thickness value and it's weight, so renderer would interpolate thickness along curve.
Is there some implementations and/or descriptions?
UPDATE
More precisely the question is follows.
Suppose we have cubic Bezier segment, controlled by 4 points ABCD
In Bezier, the longer we have vector, say AB, then the longer curve follows AB direction. On the picture above, we have raltively long following.
So, I want thikness behave synchronously with control nodes B and C. If AB and CD is long, then thinkness should follow end nodes thinkness long and change to another thickness fast, like below
and if control vectors are short, then thinkness should smoothly change from one to another, like below
Metafont and its successor MetaPost
support variable thickness in the form of shaped pens.
See also
L.M. Mestetskii, Fat curves and representation of planar figures, Computers & Graphics, 24:1 (2000) 9-21 doi: 10.1016/S0097-8493(99)00133-8
If you want to use a "disc based" approach, you need to draw circles around every control point, then find the points on those circles that represent the "offset" (normal to the tangent, for on-curve points, normal to the tangent of the projection for off-curve points). You then plug those new points into the Bezier functions to get your "offset curve".
Curve offsetting, in your case with variable width, is essentially the trick of finding an outline rather than a single curve. For Bezier curves you can find a full explanation over at http://pomax.github.io/bezierinfo/#offsetting, with the variable width explanation over at http://pomax.github.io/bezierinfo/#offsetting (you're interested in the latter, but you need to understand the basics before you look at the special case =)

Antialiased composition by coverage?

Does anyone know of a graphics system which handles composition of multiple anti-aliased lines well?
I'm showing a dependency diagram and have a bunch of curves emanating from a point. These are drawn anti-aliased in the usual way, of blending partially covered pixels. So if two lines would occupy the same half of a pixel, the antialiasing blends it to 75% filled rather than 50% filled. With enough lines drawn on top of each other, the pixel blend clamps and you end up with aliased lines.
I know anti-grain geometry has algorithms for calculating blends which cater for lines which abut, and that oversampling might work, but are there any other approaches?
Handling this form of line composition well is going to be slow (you have to consider all the lines that impinge upon each pixel using a deferred rendering approach). I doubt that there are many (if any) libraries out there that will do it for you.
The quickest and easiest method (and possibly the only realistic and cost effective solution for your case), which will work with virtually any drawing library would be to supersample it - draw to an offscreen bitmap at much higher resolution (e.g. 4 times wider and higher, with lines of 4 pixels width. Disable antialiasing when drawing this as it'll only slow it down) and then scale the result down with bilinear filtering. The main down-side is that it uses a lot of memory for the offscreen bitmap.
If you need an existing system that gets antialiased lines "visually correct", you might try using one of several existing RenderMan-compliant 3D renderers. The REYES algorithm, which many of these renderers use, works by breaking up primitives into micropolygons, then sampling them at several random point locations within each pixel. So even if you have a million lines collectively obscuring 50% of a pixel, the resulting image value will show roughly 50% coverage. (This is, for example, how the millions of antialiased hairs are drawn on characters in many animated movies.)
Of course, using a full-blown 3D renderer to draw 2D lines is like driving nails with a sledgehammer. You'd need a fairly pathological scenario for the 3D renderer to be any more efficient than simply supersampling with a traditional 2D renderer.
It sounds like you want a premade drawing library, which I do not know of.
However, to answer your question of knowing any approach that would work, you can consider a pixel to be a square. You can then approximate any shape that you draw as a polygon that intersects the pixel box. By clipping these polygons against the box of the pixel and against each other, you can get a very good estimate of the areas associated with each color that intersects the pixel for accurate antialiasing. This is, of course, very slow to calculate and is not suitable for interactive drawing.

Resources