From: <and...@us...> - 2013-11-05 13:48:36
|
Revision: 12653 http://sourceforge.net/p/plplot/code/12653 Author: andrewross Date: 2013-11-05 13:48:33 +0000 (Tue, 05 Nov 2013) Log Message: ----------- Update C example 22 to include a vector plot with a global coordinate transformation to check recent fix. Also include a filled contour plot on this page to check that plshade works ok with global transformations. This needs discussing on list before propagating to other languages. Modified Paths: -------------- trunk/examples/c/x22c.c Modified: trunk/examples/c/x22c.c =================================================================== --- trunk/examples/c/x22c.c 2013-11-05 13:47:05 UTC (rev 12652) +++ trunk/examples/c/x22c.c 2013-11-05 13:48:33 UTC (rev 12653) @@ -143,7 +143,7 @@ if ( fabs( y ) < b ) { dbdx = ymax / 4.0 * sin( M_PI * x / xmax ) * - y / b; + M_PI / xmax * y / b; u[i][j] = Q * ymax / b; v[i][j] = dbdx * u[i][j]; } @@ -168,8 +168,99 @@ } +// +// Global transform function for a constriction using data passed in +// This is the same transformation used in constriction. +// +void +transform( PLFLT x, PLFLT y, PLFLT *xt, PLFLT *yt, PLPointer data ) +{ + PLFLT *trdata; + PLFLT xmax; + trdata = (PLFLT *) data; + xmax = *trdata; + + *xt = x; + *yt = y / 4.0 * ( 3 - cos( M_PI * x / xmax ) ); +} + +// +// Vector plot of flow through a constricted pipe +// with a coordinate transform +// void +constriction2( void ) +{ + int i, j; + PLFLT dx, dy, x, y; + PLFLT xmin, xmax, ymin, ymax; + PLFLT Q, b, dbdx; + PLcGrid2 cgrid2; + PLFLT **u, **v; + const int nx = 20; + const int ny = 20; + const int nc = 11; + PLFLT clev[nc]; + + dx = 1.0; + dy = 1.0; + + xmin = -nx / 2 * dx; + xmax = nx / 2 * dx; + ymin = -ny / 2 * dy; + ymax = ny / 2 * dy; + + plstransform(transform, (PLPointer) &xmax); + + plAlloc2dGrid( &cgrid2.xg, nx, ny ); + plAlloc2dGrid( &cgrid2.yg, nx, ny ); + plAlloc2dGrid( &u, nx, ny ); + plAlloc2dGrid( &v, nx, ny ); + + cgrid2.nx = nx; + cgrid2.ny = ny; + + Q = 2.0; + for ( i = 0; i < nx; i++ ) + { + x = ( i - nx / 2 + 0.5 ) * dx; + for ( j = 0; j < ny; j++ ) + { + y = ( j - ny / 2 + 0.5 ) * dy; + cgrid2.xg[i][j] = x; + cgrid2.yg[i][j] = y; + b = ymax / 4.0 * ( 3 - cos( M_PI * x / xmax ) ); + u[i][j] = Q * ymax / b; + v[i][j] = 0.0; + } + } + + for ( i=0; i<nc; i++ ) { + clev[i] = Q + i * Q / (nc-1); + } + + plenv( xmin, xmax, ymin, ymax, 0, 0 ); + pllab( "(x)", "(y)", "#frPLplot Example 22 - constriction" ); + plcol0( 2 ); + plshades( (const PLFLT * const *) u, nx, ny, NULL, + xmin+dx/2, xmax-dx/2, ymin+dy/2, ymax-dy/2, + clev, nc, 0, 1, 1.0, plfill, 1, NULL, NULL); + plvect( (const PLFLT * const *) u, (const PLFLT * const *) v, nx, ny, + -0.5, pltr2, (void *) &cgrid2 ); + plcol0( 1 ); + + plFree2dGrid( cgrid2.xg, nx, ny ); + plFree2dGrid( cgrid2.yg, nx, ny ); + plFree2dGrid( u, nx, ny ); + plFree2dGrid( v, nx, ny ); + + plstransform(NULL, NULL); + +} + + +void f2mnmx( PLFLT **f, PLINT nx, PLINT ny, PLFLT *fnmin, PLFLT *fnmax ) { int i, j; @@ -336,6 +427,8 @@ plsvect( arrow2_x, arrow2_y, narr, fill ); constriction(); + constriction2(); + potential(); plend(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2013-11-05 14:10:31
|
Revision: 12654 http://sourceforge.net/p/plplot/code/12654 Author: andrewross Date: 2013-11-05 14:10:28 +0000 (Tue, 05 Nov 2013) Log Message: ----------- Update example 22 to include calls to plpath with a global transformation since this function is not used in any of the other examples. Modified Paths: -------------- trunk/examples/c/x22c.c Modified: trunk/examples/c/x22c.c =================================================================== --- trunk/examples/c/x22c.c 2013-11-05 13:48:33 UTC (rev 12653) +++ trunk/examples/c/x22c.c 2013-11-05 14:10:28 UTC (rev 12654) @@ -201,6 +201,7 @@ const int nx = 20; const int ny = 20; const int nc = 11; + const int nseg = 20; PLFLT clev[nc]; dx = 1.0; @@ -248,6 +249,9 @@ clev, nc, 0, 1, 1.0, plfill, 1, NULL, NULL); plvect( (const PLFLT * const *) u, (const PLFLT * const *) v, nx, ny, -0.5, pltr2, (void *) &cgrid2 ); + // Plot edges using plpath (which accounts for coordinate transformation) rather than plline + plpath(nseg,xmin,ymax,xmax,ymax); + plpath(nseg,xmin,ymin,xmax,ymin); plcol0( 1 ); plFree2dGrid( cgrid2.xg, nx, ny ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2013-11-07 22:00:50
|
Revision: 12667 http://sourceforge.net/p/plplot/code/12667 Author: andrewross Date: 2013-11-07 22:00:46 +0000 (Thu, 07 Nov 2013) Log Message: ----------- Fix from Phil Rosenberg for code which uses a const variable to initialise the size of an array. This is not strictly C compliant, though it is valid in C++. Visual studio complains about this. Modified Paths: -------------- trunk/examples/c/x22c.c Modified: trunk/examples/c/x22c.c =================================================================== --- trunk/examples/c/x22c.c 2013-11-06 02:05:21 UTC (rev 12666) +++ trunk/examples/c/x22c.c 2013-11-07 22:00:46 UTC (rev 12667) @@ -200,9 +200,10 @@ PLFLT **u, **v; const int nx = 20; const int ny = 20; - const int nc = 11; +#define NC 11 + const int nc = NC; const int nseg = 20; - PLFLT clev[nc]; + PLFLT clev[NC]; dx = 1.0; dy = 1.0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2013-11-11 21:28:55
|
Revision: 12675 http://sourceforge.net/p/plplot/code/12675 Author: airwin Date: 2013-11-11 21:28:53 +0000 (Mon, 11 Nov 2013) Log Message: ----------- Style previous commit. Modified Paths: -------------- trunk/examples/c/x22c.c Modified: trunk/examples/c/x22c.c =================================================================== --- trunk/examples/c/x22c.c 2013-11-10 01:14:57 UTC (rev 12674) +++ trunk/examples/c/x22c.c 2013-11-11 21:28:53 UTC (rev 12675) @@ -198,9 +198,9 @@ PLFLT Q, b, dbdx; PLcGrid2 cgrid2; PLFLT **u, **v; - const int nx = 20; - const int ny = 20; -#define NC 11 + const int nx = 20; + const int ny = 20; +#define NC 11 const int nc = NC; const int nseg = 20; PLFLT clev[NC]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2013-11-21 22:52:41
|
Revision: 12734 http://sourceforge.net/p/plplot/code/12734 Author: andrewross Date: 2013-11-21 22:52:38 +0000 (Thu, 21 Nov 2013) Log Message: ----------- Further tweaks to example 22 to make the arrows larger (and easier to see). This highlights the difference between filled and unfilled arrows. Also demonstrate use of NULL arguments to plsvect to reset arrow style to default. Modified Paths: -------------- trunk/examples/c/x22c.c Modified: trunk/examples/c/x22c.c =================================================================== --- trunk/examples/c/x22c.c 2013-11-21 22:19:11 UTC (rev 12733) +++ trunk/examples/c/x22c.c 2013-11-21 22:52:38 UTC (rev 12734) @@ -31,10 +31,10 @@ void f2mnmx( PLFLT **f, PLINT nx, PLINT ny, PLFLT *fnmin, PLFLT *fnmax ); // Pairs of points making the line segments used to plot the user defined arrow -static PLFLT arrow_x[6] = { -0.5, 0.5, 0.3, 0.5, 0.3, 0.5 }; -static PLFLT arrow_y[6] = { 0.0, 0.0, 0.2, 0.0, -0.2, 0.0 }; -static PLFLT arrow2_x[6] = { -0.5, 0.3, 0.3, 0.5, 0.3, 0.3 }; -static PLFLT arrow2_y[6] = { 0.0, 0.0, 0.2, 0.0, -0.2, 0.0 }; +static PLFLT arrow_x[6] = { -1.0, 1.0, 0.6, 1.0, 0.6, 1.0 }; +static PLFLT arrow_y[6] = { 0.0, 0.0, 0.4, 0.0, -0.4, 0.0 }; +static PLFLT arrow2_x[6] = { -1.0, 0.6, 0.6, 1.0, 0.6, 0.6 }; +static PLFLT arrow2_y[6] = { 0.0, 0.0, 0.4, 0.0, -0.4, 0.0 }; //-------------------------------------------------------------------------- // main @@ -434,6 +434,10 @@ constriction2(); + // Reset arrow style to the default by passing two + // NULL arrays + plsvect( NULL, NULL, 0, 0); + potential(); plend(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <and...@us...> - 2013-11-24 21:41:40
|
Revision: 12746 http://sourceforge.net/p/plplot/code/12746 Author: andrewross Date: 2013-11-24 21:41:37 +0000 (Sun, 24 Nov 2013) Log Message: ----------- Add distinct titles to the constriction plots. Modified Paths: -------------- trunk/examples/c/x22c.c Modified: trunk/examples/c/x22c.c =================================================================== --- trunk/examples/c/x22c.c 2013-11-23 23:37:35 UTC (rev 12745) +++ trunk/examples/c/x22c.c 2013-11-24 21:41:37 UTC (rev 12746) @@ -26,7 +26,7 @@ #include "plcdemos.h" void circulation( void ); -void constriction( void ); +void constriction( int ); void potential( void ); void f2mnmx( PLFLT **f, PLINT nx, PLINT ny, PLFLT *fnmin, PLFLT *fnmax ); @@ -103,7 +103,7 @@ // Vector plot of flow through a constricted pipe // void -constriction( void ) +constriction( int astyle ) { int i, j; PLFLT dx, dy, x, y; @@ -113,6 +113,7 @@ PLFLT **u, **v; const int nx = 20; const int ny = 20; + char title[80]; dx = 1.0; dy = 1.0; @@ -156,7 +157,8 @@ } plenv( xmin, xmax, ymin, ymax, 0, 0 ); - pllab( "(x)", "(y)", "#frPLplot Example 22 - constriction" ); + sprintf( title, "#frPLplot Example 22 - constriction (arrow style %d)", astyle ); + pllab( "(x)", "(y)", title ); plcol0( 2 ); plvect( (const PLFLT * const *) u, (const PLFLT * const *) v, nx, ny, -0.5, pltr2, (void *) &cgrid2 ); plcol0( 1 ); @@ -244,7 +246,7 @@ } plenv( xmin, xmax, ymin, ymax, 0, 0 ); - pllab( "(x)", "(y)", "#frPLplot Example 22 - constriction" ); + pllab( "(x)", "(y)", "#frPLplot Example 22 - constriction with plstransform" ); plcol0( 2 ); plshades( (const PLFLT * const *) u, nx, ny, NULL, xmin + dx / 2, xmax - dx / 2, ymin + dy / 2, ymax - dy / 2, @@ -424,13 +426,13 @@ // Set arrow style using arrow_x and arrow_y then // plot using these arrows. plsvect( arrow_x, arrow_y, narr, fill ); - constriction(); + constriction( 1 ); // Set arrow style using arrow2_x and arrow2_y then // plot using these filled arrows. fill = 1; plsvect( arrow2_x, arrow2_y, narr, fill ); - constriction(); + constriction( 2 ); constriction2(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |