# Setting TikZ curve control points and preserve area of closed curve

I would like to reproduce the shown periodic table, with more correct areas.

http://www.meta-synthesis.com/webbook/35_pt/relative_abundance.jpg

I would appreciate any ideas to how this can be done. How do I in TikZ calculate the area of one box? Can I make the control points auto adjust to a given area, either by iteration, or direct calculation. I do not know the math behind control points!?

Code sample:

\documentclass{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw (0,0) rectangle (3,2);
\draw (0,1) .. controls (0.4,0.4) and (1.5,1.5) ..  (3,1);
\draw (1,0) .. controls (0.4,0.4) and (1.5,1.5) ..  (1,2);
\draw (2,0) .. controls (1.4,1.4) and (1.5,1.5) ..  (2,2);
\end{tikzpicture}
\end{document}


Output:

-
Seems as if (1) you have rectangular shapes (2) each consists of 4 bezier curves. You could try the pgfplots library patchplots with patch type=biquadratic or patch type=bicubic... they would require points ON the boundary curves which makes things a little bit simpler. – Christian Feuersänger Nov 25 '12 at 13:44
– cjorssen Jan 17 '13 at 9:07
@cjorssen: This is really great. I did not know that there was a special name for this kind of mapping - it is helping me a lot. I will look into it, and try to make some TikZ code from it. – Hans-Peter E. Kristiansen Mar 22 '13 at 3:19

Is there any reason it has to be in TikZ? For what is probably a one-off large calculation it may be better to do all the calculation in some other environment and use this to generate a TikZ picture. For example a programming/scripting language or a CAS. Metapost has paths/points and easy access to Bezier points, so that could be the go. Yes, I know that this counter to the spirit of "{tikz-pgf}{calculations}".

In any case, a component of what you need is a formula for the area of a Bezier-bounded region. This can be found using standard multivariate calculus tricks (in particular Green's theorem - Kreyszig chapter 10 if you have it). There are some formulas where someone has done exactly that here:

http://objectmix.com/graphics/133553-area-closed-bezier-curve.html

I am assuming that this is what you meant by not understanding the maths behind control points. More fundamental information is here: http://en.wikipedia.org/wiki/Bezier_curve

For the rest of the problem, I'd use an iterative approach - move points in the direction that improves the fit. It would probably take a fair bit of fiddling to find the right combination of freedom and restrictions. One advantage if you do it in Metapost is that it does a reasonable job of calculating nice control points if you just give it a sequence of endpoints.

Apologies that this is not a perfectly-solved answer to your question - it would be quite complicated to actually get it working.

-