<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta name="generator" content="pdf2htmlEX">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<link rel="stylesheet" href="https://static.pudn.com/base/css/base.min.css">
<link rel="stylesheet" href="https://static.pudn.com/base/css/fancy.min.css">
<link rel="stylesheet" href="https://static.pudn.com/prod/directory_preview_static/622b323e81ded46b7f2dad5c/raw.css">
<script src="https://static.pudn.com/base/js/compatibility.min.js"></script>
<script src="https://static.pudn.com/base/js/pdf2htmlEX.min.js"></script>
<script>
try{
pdf2htmlEX.defaultViewer = new pdf2htmlEX.Viewer({});
}catch(e){}
</script>
<title></title>
</head>
<body>
<div id="sidebar" style="display: none">
<div id="outline">
</div>
</div>
<div id="pf1" class="pf w0 h0" data-page-no="1"><div class="pc pc1 w0 h0"><img class="bi x0 y0 w1 h1" alt="" src="https://static.pudn.com/prod/directory_preview_static/622b323e81ded46b7f2dad5c/bg1.jpg"><div class="c x0 y1 w2 h2"><div class="t m0 x1 h3 y2 ff1 fs0 fc0 sc0 ls0 ws0">W<span class="_ _0"></span>ell, Thanks t<span class="_ _1"></span>o all you folks who replied, I now have a contour plotting</div><div class="t m0 x1 h3 y3 ff1 fs0 fc0 sc0 ls0 ws0">routine, that does its job fairly well. I\'ve posted this code below<span class="_ _0"></span>. It </div><div class="t m0 x1 h3 y4 ff1 fs0 fc0 sc0 ls0 ws0">is not nearly runnable as other Unix programs go, but you could use it</div><div class="t m0 x1 h3 y5 ff1 fs0 fc0 sc0 ls0 ws0">if you need C code to start off with to do conto<span class="_ _1"></span>ur plotting.</div><div class="t m0 x1 h3 y6 ff1 fs0 fc0 sc0 ls0 ws0">It doesn\'t handle stuff lik<span class="_ _1"></span>e labelling etc. which is somewhat tricky<span class="_ _0"></span>.</div><div class="t m0 x1 h3 y7 ff1 fs0 fc0 sc0 ls0 ws0">Basically almost all of the respondents suggested dividing up the set of </div><div class="t m0 x1 h3 y8 ff1 fs0 fc0 sc0 ls0 ws0">discrete points into a set of triangles and then computing the intersection</div><div class="t m0 x1 h3 y9 ff1 fs0 fc0 sc0 ls0 ws0">of these rectangles with planes representing the contour levels. <span class="_ _1"></span>This way</div><div class="t m0 x1 h3 ya ff1 fs0 fc0 sc0 ls0 ws0">we can process all the levels at once instead of the "crawler" type algorithms</div><div class="t m0 x1 h3 yb ff1 fs0 fc0 sc0 ls0 ws0">which is what I had originally been trying to get to work.</div><div class="t m0 x1 h3 yc ff1 fs0 fc0 sc0 ls0 ws0">T<span class="_ _0"></span>o summarize their ideas: if P1=P[j],P2=P[i+1][j],P3=P[i+1][j+1]</div><div class="t m0 x1 h3 yd ff1 fs0 fc0 sc0 ls0 ws0">and P4=P[j+1] are four points, compute an intermediate point using</div><div class="t m0 x1 h3 ye ff1 fs0 fc0 sc0 ls0 ws0">an interpolation scheme (in the code below<span class="_ _0"></span>, I just use averaging, but</div><div class="t m0 x1 h3 yf ff1 fs0 fc0 sc0 ls0 ws0">one could obviously use fancier schemes). If this point is P<span class="_ _2"></span>, then the</div><div class="t m0 x1 h3 y10 ff1 fs0 fc0 sc0 ls0 ws0">foll. four triangles are used to compute the intersections with</div><div class="t m0 x1 h3 y11 ff1 fs0 fc0 sc0 ls0 ws0">contour levels l_0, .. l_n: P1 P2 P<span class="_ _2"></span>, P2 P3 P<span class="_ _2"></span>, P3 P4 P<span class="_ _2"></span>, P4 P1 P<span class="_ _0"></span>.</div><div class="t m0 x1 h3 y12 ff1 fs0 fc0 sc0 ls0 ws0">The intersection computation is quite trivial. Once these line segments have been</div><div class="t m0 x1 h3 y13 ff1 fs0 fc0 sc0 ls0 ws0">computed you could smooth them in 2d (the code below doesn\'t).</div><div class="t m0 x1 h3 y14 ff1 fs0 fc0 sc0 ls0 ws0">(see Michael <span class="_ _3"></span>Aramini\'s earlier posting for a variation on this that uses </div><div class="t m0 x1 h3 y15 ff1 fs0 fc0 sc0 ls0 ws0">rectangles directly -- He also mentions that you could use the diagonal edges</div><div class="t m0 x1 h3 y16 ff1 fs0 fc0 sc0 ls0 ws0">between two vertices instead of computing another intermediate point, but this</div><div class="t m0 x1 h3 y17 ff1 fs0 fc0 sc0 ls0 ws0">method has problems).</div><div class="t m0 x1 h3 y18 ff1 fs0 fc0 sc0 ls0 ws0">-Sundar</div><div class="t m0 x1 h3 y19 ff1 fs0 fc0 sc0 ls0 ws0">-----Sample Code Follows----------</div><div class="t m0 x1 h3 y1a ff1 fs0 fc0 sc0 ls0 ws0">/*</div><div class="t m0 x1 h3 y1b ff1 fs0 fc0 sc0 ls0 ws0">* If you want try using this, you probably would need to provide</div><div class="t m0 x1 h3 y1c ff1 fs0 fc0 sc0 ls0 ws0">* graph_set_point(), and graph_draw_line(), besides do things like</div><div class="t m0 x1 h3 y1d ff1 fs0 fc0 sc0 ls0 ws0">* initialize window systems and so on.</div><div class="t m0 x1 h3 y1e ff1 fs0 fc0 sc0 ls0 ws0">*</div><div class="t m0 x1 h3 y1f ff1 fs0 fc0 sc0 ls0 ws0">* Please see the code for a note about data format</div><div class="t m0 x1 h3 y20 ff1 fs0 fc0 sc0 ls0 ws0">*/</div><div class="t m0 x1 h3 y21 ff1 fs0 fc0 sc0 ls0 ws0">/* Definitions */</div><div class="t m0 x1 h3 y22 ff1 fs0 fc0 sc0 ls0 ws0">struct _array {</div><div class="t m0 x1 h3 y23 ff1 fs0 fc0 sc0 ls0 ws0"> float *a_elements;</div><div class="t m0 x1 h3 y24 ff1 fs0 fc0 sc0 ls0 ws0"> int a_rows;</div><div class="t m0 x1 h3 y25 ff1 fs0 fc0 sc0 ls0 ws0"> int a_cols;</div><div class="t m0 x1 h3 y26 ff1 fs0 fc0 sc0 ls0 ws0"> float *a_filler;</div></div></div><div class="pi" data-data='{"ctm":[1.611850,0.000000,0.000000,1.611850,0.000000,0.000000]}'></div></div>
</body>
</html>