Ways to implement contour graphics

I need to implement an algorithm for constructing a contour (as opposed to using it). Input is a (continuous) function f: R ^ 2 β†’ R (the function is defined throughout the region, and not just for certain inputs). The output should be in vector form, that is, in a set of splines or line segments.

I am looking for recommendations on how to implement this, preferably in the form of (scientific) work.

I found several links to algorithms developed in the 80s ("Level Tracking Algorithm"). Have there been any developments in this area over the past 30 years? What is the standard method (s) used to solve this problem?

The algorithm will be used for real-time visualization, so it should be fast, while maintaining decent results.

(Small, stand-alone, and well-tested C / C ++ implementations will also be welcomed.)

+3
source share
4 answers

I remember that the TI-89 calculator used a very simple scheme:

  • Make a grid, experiment with cell size
  • Calculate your function at each vertex of the grid
  • For each square, if there are two f values ​​with different signs, there is something interesting inside. Suppose this is the following:
    • For each β€œinteresting” side of the square (f has different signs at the end points), find the zero of f on the side by dividing in half (or by linear interpolation if you are on a low budget). There may be two or four interesting sides.
    • If there are two interesting sides, draw a straight line between the zero points.
    • , .

. TI-89 (160x120), . .

+5
+2

: , f(x,y) = Z Z. D = subset(RxR) , M = (V,E,r), M - , V - , E - , r > - , level of detail, LOD. V f. E , (e[k]) f (v[i] v[j]) Z, f(v[i])>Z f(v[j])<Z. , f(x,y) = Z e[k] (c[k]), :

t = (f (v [i]) - Z)/(f (v [i]) - f (v [j]))
c '[k] = v [i] * (1-t) + v [j] * t

( ), c'[k]. , M , , . f(x,y)=Z r. r , r .

+1

I think you need to make data arrays f [i, j] for your function in some grid, collect a line segment from each cell and connect them later with the curve (s). You should keep in mind the possible circles (i.e. the presence of several closed curves in the grid). It is this algorithm that is used in MathGL (cross-platform library for building the GPL) - see the implementation of the mglGraph :: Cont () function.

0
source

Source: https://habr.com/ru/post/1777658/


All Articles