On Monday, April 19, 2010 at 22:35:33 (-0700) Alan W. Irwin writes:
> On 2010-04-19 22:21-0500 Maurice LeBrun wrote:
> > [...]
> > Note, people doing polar plots (shades or contours) have to similarly
> > massage
> > their data before passing it to plplot in order to pick up the continuity
> > condition at angle 0 = 2pi. One could claim this is an important effect
> > for
> > the library to handle natively, but frankly I've never seen the need,
> > preferring a leaner and more easily maintained API. This is illustrated
> > (rather quietly) in the final (polar) plot of example 16, where the angle
> > coordinate value runs from 0 to 2pi inclusive -- providing a duplicated
> > data
> > point to enforce continuity.
>
> Hi Ed:
>
> Let me add a bit more to what Maurice said by talking about a specific
> example. Suppose the function you are plotting is theta(x,y), where theta =
> arctan2(y, x) In this (simple) case, there is obviously a 2 pi discontinuity
> in theta at +/- pi. For lack of a better term, let's call that an
> angle range discontinuity.
>
> I don't have a lot of experience with the plcont API, but I know it is quite
> general and the "Contour and Shade PLot" section of our documentation at
> http://plplot.sourceforge.net/docbook-manual/plplot-html-5.9.5/contour-plots.html
> says the following:
>
> "Examples of the use of these transformation routines are given in
> examples/c/x09c.c, examples/c/x14c.c, and examples/c/x16c.c. These same
> three examples also demonstrate a user-defined transformation function
> mypltr which is capable of arbitrary translation, rotation, and/or shear. By
> defining other transformation subroutines, it is possible to draw contours
> wrapped around polar grids etc."
>
> It appears to me that last sentence is stating the user-defined
> transformation function is the proper way to deal with contouring of angular
> data with range discontinuities like the simple example above. The same
> approach may allow you to deal properly with your more general case of a
> phase range discontinuity occuring at arbitrary curves in the x, y, plane.
> Maurice, do you agree or was there something else you had in mind?
The general remapping of coordinates is a crucial part of it. I was also
pointing out how one can achieve a specific functional boundary condition
i.e. f(r, 0) == f(r, 2pi) on a polar grid without having to support that in
plplot per se. Typically when one discretizes space it's a one-to-one mapping
between grid indices and spatial coordinates barring degenerate points like
r=0 (which I have never liked and tend to avoid if possible). If you do a
contour or shade plot for such a "regular" discretization in polar
coordinates, IIRC you end up with a plot that looks like a pie with a slice
cut out of it -- because the contourer and shader know nothing about your
boundary condition. You've just taken a rectangular grid and stretched it
around until it approximates a circle. To "fill in the pie slice" you need to
add in an "extra" gridpoint at 2pi. It's redundant, so anathema to the
central loops in a simulation code, but makes the diagnostic give the result
you want. So in this case the wrapper function is called for.
In example 16 you can see the wrap-around in theta clearly:
for ( i = 0; i < nx; i++ )
{
r = ( (PLFLT) i ) / ( nx - 1 );
for ( j = 0; j < ny; j++ )
{
t = ( 2. * M_PI / ( ny - 1. ) ) * j;
cgrid2.xg[i][j] = r * cos( t );
cgrid2.yg[i][j] = r * sin( t );
z[i][j] = exp( -r * r ) * cos( 5. * M_PI * r ) * cos( 5. *
t );
}
}
although like I mentioned it's not well-advertised. Sorry..
--
Maurice LeBrun
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Plplot-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/plplot-devel