From: <ai...@us...> - 2014-03-05 00:58:05
|
Revision: 13039 http://sourceforge.net/p/plplot/code/13039 Author: airwin Date: 2014-03-05 00:58:02 +0000 (Wed, 05 Mar 2014) Log Message: ----------- Add a 4th (and 8th) page that demonstrates plsurf3dl results for Y index ranges that follow an ellipse (subject to integer quantization). Modified Paths: -------------- trunk/examples/c/x08c.c Modified: trunk/examples/c/x08c.c =================================================================== --- trunk/examples/c/x08c.c 2014-03-04 21:09:29 UTC (rev 13038) +++ trunk/examples/c/x08c.c 2014-03-05 00:58:02 UTC (rev 13039) @@ -132,6 +132,18 @@ PLINT nlevel = LEVELS; int rosen = 1; + PLINT indexxmin = 0; + PLINT indexxmax = XPTS; + PLINT *indexymin; + PLINT *indexymax; + PLFLT **zlimited; + // parameters of ellipse that limits the data. + PLFLT x0 = 0.5*(PLFLT) (XPTS - 1); + PLFLT a = x0; + PLFLT y0 = 0.5*(PLFLT) (YPTS - 1); + PLFLT b = y0; + PLFLT square_root; + // Parse and process command line arguments plMergeOpts( options, "x08c options", NULL ); (void) plparseopts( &argc, argv, PL_PARSE_FULL ); @@ -200,6 +212,25 @@ } } + // Allocate and alculate y index ranges and corresponding zlimited. + plAlloc2dGrid( &zlimited, XPTS, YPTS ); + indexymin = (PLINT *) malloc( XPTS * sizeof ( PLINT ) ); + indexymax = (PLINT *) malloc( XPTS * sizeof ( PLINT ) ); + if ( !indexymin || !indexymax ) + plexit( "Memory allocation error" ); + + for ( i = indexxmin; i < indexxmax; i++ ) + { + square_root = sqrt(1. - MIN(1., pow(((PLFLT)i - x0)/a, 2.))); + indexymin[i] = MAX(0, (PLINT)(y0 - b*square_root)); + indexymax[i] = MIN(YPTS, (PLINT)(y0 + b*square_root)); + for ( j = indexymin[i]; j < indexymax[i]; j++ ) + { + zlimited[i][j] = z[i][j]; + } + } + + plMinMax2dGrid( (const PLFLT * const *) z, XPTS, YPTS, &zmax, &zmin ); step = ( zmax - zmin ) / ( nlevel + 1 ); for ( i = 0; i < nlevel; i++ ) @@ -209,7 +240,7 @@ for ( k = 0; k < 2; k++ ) { - for ( ifshade = 0; ifshade < 4; ifshade++ ) + for ( ifshade = 0; ifshade < 5; ifshade++ ) { pladv( 0 ); plvpor( 0.0, 1.0, 0.0, 0.9 ); @@ -242,11 +273,16 @@ cmap1_init( 0 ); plfsurf3d( x, y, plf2ops_grid_row_major(), ( PLPointer ) & grid_row_major, XPTS, YPTS, MAG_COLOR | FACETED, NULL, 0 ); } - else // magnitude colored plot with contours + else if ( ifshade == 3 ) // magnitude colored plot with contours { cmap1_init( 0 ); plfsurf3d( x, y, plf2ops_grid_col_major(), ( PLPointer ) & grid_col_major, XPTS, YPTS, MAG_COLOR | SURF_CONT | BASE_CONT, clevel, nlevel ); } + else // magnitude colored plot with contours and index limits. + { + cmap1_init( 0 ); + plsurf3dl( x, y, (const PLFLT * const*) zlimited, XPTS, YPTS, MAG_COLOR | SURF_CONT | BASE_CONT, clevel, nlevel, indexxmin, indexxmax, indexymin, indexymax ); + } } } @@ -258,6 +294,10 @@ free( (void *) z_row_major ); free( (void *) z_col_major ); + plFree2dGrid( zlimited, XPTS, YPTS ); + free( (void *) indexymin ); + free( (void *) indexymax ); + plend(); exit( 0 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ai...@us...> - 2014-03-05 01:23:04
|
Revision: 13040 http://sourceforge.net/p/plplot/code/13040 Author: airwin Date: 2014-03-05 01:22:58 +0000 (Wed, 05 Mar 2014) Log Message: ----------- Style previous commit. Modified Paths: -------------- trunk/examples/c/x08c.c Modified: trunk/examples/c/x08c.c =================================================================== --- trunk/examples/c/x08c.c 2014-03-05 00:58:02 UTC (rev 13039) +++ trunk/examples/c/x08c.c 2014-03-05 01:22:58 UTC (rev 13040) @@ -138,10 +138,10 @@ PLINT *indexymax; PLFLT **zlimited; // parameters of ellipse that limits the data. - PLFLT x0 = 0.5*(PLFLT) (XPTS - 1); - PLFLT a = x0; - PLFLT y0 = 0.5*(PLFLT) (YPTS - 1); - PLFLT b = y0; + PLFLT x0 = 0.5 * (PLFLT) ( XPTS - 1 ); + PLFLT a = x0; + PLFLT y0 = 0.5 * (PLFLT) ( YPTS - 1 ); + PLFLT b = y0; PLFLT square_root; // Parse and process command line arguments @@ -221,13 +221,13 @@ for ( i = indexxmin; i < indexxmax; i++ ) { - square_root = sqrt(1. - MIN(1., pow(((PLFLT)i - x0)/a, 2.))); - indexymin[i] = MAX(0, (PLINT)(y0 - b*square_root)); - indexymax[i] = MIN(YPTS, (PLINT)(y0 + b*square_root)); - for ( j = indexymin[i]; j < indexymax[i]; j++ ) - { - zlimited[i][j] = z[i][j]; - } + square_root = sqrt( 1. - MIN( 1., pow( ( (PLFLT) i - x0 ) / a, 2. ) ) ); + indexymin[i] = MAX( 0, (PLINT) ( y0 - b * square_root ) ); + indexymax[i] = MIN( YPTS, (PLINT) ( y0 + b * square_root ) ); + for ( j = indexymin[i]; j < indexymax[i]; j++ ) + { + zlimited[i][j] = z[i][j]; + } } @@ -281,7 +281,7 @@ else // magnitude colored plot with contours and index limits. { cmap1_init( 0 ); - plsurf3dl( x, y, (const PLFLT * const*) zlimited, XPTS, YPTS, MAG_COLOR | SURF_CONT | BASE_CONT, clevel, nlevel, indexxmin, indexxmax, indexymin, indexymax ); + plsurf3dl( x, y, (const PLFLT * const *) zlimited, XPTS, YPTS, MAG_COLOR | SURF_CONT | BASE_CONT, clevel, nlevel, indexxmin, indexxmax, indexymin, indexymax ); } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |