[Plplot-cvs] SF.net SVN: plplot:[10691] trunk/src/plot3d.c From: - 2009-12-06 23:10 ```Revision: 10691 http://plplot.svn.sourceforge.net/plplot/?rev=10691&view=rev Author: airwin Date: 2009-12-06 23:10:50 +0000 (Sun, 06 Dec 2009) Log Message: ----------- Style previous change. Modified Paths: -------------- trunk/src/plot3d.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2009-12-06 22:50:51 UTC (rev 10690) +++ trunk/src/plot3d.c 2009-12-06 23:10:50 UTC (rev 10691) @@ -2610,14 +2610,14 @@ * where t is the rotation angle and p is the shear angle. * The purpose of this routine is to determine stride, rotation angle, * and shear angle from xFormMatrix. - + * * For information only, xFormMatrix is the product of the following * rotation, skew(shear), and scale matrices: * * [stride 0] [1 0] [cos(t) sin(t)] * [0 cos(p)] [tan(p) 1] [-sin(t) cos(t)] * - \*--------------------------------------------------------------------------*/ + \*--------------------------------------------------------------------------*/ void plRotationShear( PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride ) @@ -2636,48 +2636,48 @@ /* N.B. Sometimes xFormMatrix[3] can wander outside the range from * -1. to 1. due to numerical errors so must protect against that * to avoid NaN's. */ - if(fabs(xFormMatrix[3]) <= 1.) - smr = acos(xFormMatrix[3]); - else if(xFormMatrix[3] < -1.) - smr = PI; + if ( fabs( xFormMatrix[3] ) <= 1. ) + smr = acos( xFormMatrix[3] ); + else if ( xFormMatrix[3] < -1. ) + smr = PI; else - smr = 0.; + smr = 0.; if ( xFormMatrix[1] < 0.0 ) { - smr = -smr; + smr = -smr; } /* Calculate shear in range from -2 pi to 2 pi. */ *shear = smr + *rotation; /* Calculate shear in range from -pi to pi. */ - if(*shear < -PI) - *shear += 2.*PI; - else if(*shear > PI) - *shear -= 2.*PI; + if ( *shear < -PI ) + *shear += 2. * PI; + else if ( *shear > PI ) + *shear -= 2. * PI; /* Actually must honour some convention to calculate the negative * of the shear angle instead of the shear angle. Why??*/ - *shear = - *shear; + *shear = -*shear; /* Comment out the modified old logic which determines the negative * of the shear angle in a more complicated way. Note, the modification * to divide the asin argument by *stride which solved a long-standing * bug (as does the above logic in a simpler way). */ /* - *shear = -asin( (xFormMatrix[0] * xFormMatrix[1] + - xFormMatrix[2] * xFormMatrix[3] )/ *stride); - */ + *shear = -asin( (xFormMatrix[0] * xFormMatrix[1] + + * xFormMatrix[2] * xFormMatrix[3] )/ *stride); + */ /* Compute the cross product of the vectors [1,0] and [0,1] to * determine if we need to make a "quadrant 3,4" adjustment * to the shear angle. */ /* - if ( xFormMatrix[0] * xFormMatrix[3] - xFormMatrix[1] * xFormMatrix[2] < 0.0 ) - { - *shear = -( M_PI + *shear ); - } - */ + * if ( xFormMatrix[0] * xFormMatrix[3] - xFormMatrix[1] * xFormMatrix[2] < 0.0 ) + * { + *shear = -( M_PI + *shear ); + * } + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Plplot-cvs] SF.net SVN: plplot:[10691] trunk/src/plot3d.c From: - 2009-12-06 23:10 ```Revision: 10691 http://plplot.svn.sourceforge.net/plplot/?rev=10691&view=rev Author: airwin Date: 2009-12-06 23:10:50 +0000 (Sun, 06 Dec 2009) Log Message: ----------- Style previous change. Modified Paths: -------------- trunk/src/plot3d.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2009-12-06 22:50:51 UTC (rev 10690) +++ trunk/src/plot3d.c 2009-12-06 23:10:50 UTC (rev 10691) @@ -2610,14 +2610,14 @@ * where t is the rotation angle and p is the shear angle. * The purpose of this routine is to determine stride, rotation angle, * and shear angle from xFormMatrix. - + * * For information only, xFormMatrix is the product of the following * rotation, skew(shear), and scale matrices: * * [stride 0] [1 0] [cos(t) sin(t)] * [0 cos(p)] [tan(p) 1] [-sin(t) cos(t)] * - \*--------------------------------------------------------------------------*/ + \*--------------------------------------------------------------------------*/ void plRotationShear( PLFLT *xFormMatrix, PLFLT *rotation, PLFLT *shear, PLFLT *stride ) @@ -2636,48 +2636,48 @@ /* N.B. Sometimes xFormMatrix[3] can wander outside the range from * -1. to 1. due to numerical errors so must protect against that * to avoid NaN's. */ - if(fabs(xFormMatrix[3]) <= 1.) - smr = acos(xFormMatrix[3]); - else if(xFormMatrix[3] < -1.) - smr = PI; + if ( fabs( xFormMatrix[3] ) <= 1. ) + smr = acos( xFormMatrix[3] ); + else if ( xFormMatrix[3] < -1. ) + smr = PI; else - smr = 0.; + smr = 0.; if ( xFormMatrix[1] < 0.0 ) { - smr = -smr; + smr = -smr; } /* Calculate shear in range from -2 pi to 2 pi. */ *shear = smr + *rotation; /* Calculate shear in range from -pi to pi. */ - if(*shear < -PI) - *shear += 2.*PI; - else if(*shear > PI) - *shear -= 2.*PI; + if ( *shear < -PI ) + *shear += 2. * PI; + else if ( *shear > PI ) + *shear -= 2. * PI; /* Actually must honour some convention to calculate the negative * of the shear angle instead of the shear angle. Why??*/ - *shear = - *shear; + *shear = -*shear; /* Comment out the modified old logic which determines the negative * of the shear angle in a more complicated way. Note, the modification * to divide the asin argument by *stride which solved a long-standing * bug (as does the above logic in a simpler way). */ /* - *shear = -asin( (xFormMatrix[0] * xFormMatrix[1] + - xFormMatrix[2] * xFormMatrix[3] )/ *stride); - */ + *shear = -asin( (xFormMatrix[0] * xFormMatrix[1] + + * xFormMatrix[2] * xFormMatrix[3] )/ *stride); + */ /* Compute the cross product of the vectors [1,0] and [0,1] to * determine if we need to make a "quadrant 3,4" adjustment * to the shear angle. */ /* - if ( xFormMatrix[0] * xFormMatrix[3] - xFormMatrix[1] * xFormMatrix[2] < 0.0 ) - { - *shear = -( M_PI + *shear ); - } - */ + * if ( xFormMatrix[0] * xFormMatrix[3] - xFormMatrix[1] * xFormMatrix[2] < 0.0 ) + * { + *shear = -( M_PI + *shear ); + * } + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot:[10696] trunk/src/plot3d.c From: - 2009-12-07 07:35 ```Revision: 10696 http://plplot.svn.sourceforge.net/plplot/?rev=10696&view=rev Author: airwin Date: 2009-12-07 07:34:55 +0000 (Mon, 07 Dec 2009) Log Message: ----------- Simplify plRotationShear logic a bit more by using atan2. Modified Paths: -------------- trunk/src/plot3d.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2009-12-07 07:05:23 UTC (rev 10695) +++ trunk/src/plot3d.c 2009-12-07 07:34:55 UTC (rev 10696) @@ -2626,28 +2626,11 @@ *stride = sqrt( xFormMatrix[0] * xFormMatrix[0] + xFormMatrix[2] * xFormMatrix[2] ); /* Calculate rotation in range from -pi to pi. */ - *rotation = acos( xFormMatrix[0] / *stride ); - if ( xFormMatrix[2] < 0.0 ) - { - *rotation = -*rotation; - } + *rotation = atan2( xFormMatrix[2], xFormMatrix[0] ); /* Calculate shear - rotation in range from -pi to pi. */ - /* N.B. Sometimes xFormMatrix[3] can wander outside the range from - * -1. to 1. due to numerical errors so must protect against that - * to avoid NaN's. */ - if ( fabs( xFormMatrix[3] ) <= 1. ) - smr = acos( xFormMatrix[3] ); - else if ( xFormMatrix[3] < -1. ) - smr = PI; - else - smr = 0.; + smr = atan2( xFormMatrix[1], xFormMatrix[3] ); - if ( xFormMatrix[1] < 0.0 ) - { - smr = -smr; - } - /* Calculate shear in range from -2 pi to 2 pi. */ *shear = smr + *rotation; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot:[11461] trunk/src/plot3d.c From: - 2011-01-10 20:49 ```Revision: 11461 http://plplot.svn.sourceforge.net/plplot/?rev=11461&view=rev Author: airwin Date: 2011-01-10 20:49:45 +0000 (Mon, 10 Jan 2011) Log Message: ----------- AWI for David MacMahon. Add doxygen comments to plfplot3dcl. (This is David's original patch with spelling fixed + trivial doxygen documentation of whole file added.) Modified Paths: -------------- trunk/src/plot3d.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2011-01-09 20:14:12 UTC (rev 11460) +++ trunk/src/plot3d.c 2011-01-10 20:49:45 UTC (rev 11461) @@ -1,7 +1,9 @@ // \$Id\$ // -// 3d plot routines. -// +//! @file +//! +//! 3d plot routines. +//! // Copyright (C) 2004 Alan W. Irwin // Copyright (C) 2004 Joao Cardoso // Copyright (C) 2004 Andrew Ross @@ -923,6 +925,47 @@ opt, clevel, nlevel, ixstart, ixn, indexymin, indexymax ); } +//-------------------------------------------------------------------------- +//! Plots a 3-d representation of the virtual function z, which is represented +//! by zops and zp. +//! +//! @param x The x values are stored as x[0..nx-1] +//! @param y The y values are stored as y[0..ny-1] +//! @param zops Pointer to a plf2ops_t structure of function pointers (see +//! plf2opts_t in plplot.h) which define how to perform various manipulations +//! (including retrieval) on the elements of the the 2D data field pointed to +//! by zp. Pointers suitable for passing as zops can be obtained for some +//! predefined types of 2-d data storage by calling one of the plf2ops_*() +//! functions (see plf2ops.c) or you can create your own set for arbitrary 2-d +//! storage formats. +//! @param zp Pointer to 2D data field. This pointer is passed to the +//! functions of zops whenever the 2D field needs to be manipulated. The +//! combination of zops and zp provides total flexibility in how the underlying +//! data values are managed. +//! @param nx The number of values in x. +//! @param ny The number of values in y. +//! @param opt Specifies options for the plot. It can be a bitwise OR-ing of +//! these: +//! - DRAW_LINEX : Draw lines parallel to x-axis +//! - DRAW_LINEY : Draw lines parallel to y-axis +//! - DRAW_LINEXY: Draw lines parallel to both axes +//! - MAG_COLOR: Magnitude coloring of wire frame +//! - BASE_CONT: Draw contour at bottom xy plane +//! - TOP_CONT: Draw contour at top xy plane (not yet) +//! - DRAW_SIDES: Draw sides around the plot +//! - MESH: Draw the "under" side of the plot +//! or any bitwise OR'd combination, e.g. "MAG_COLOR | DRAW_LINEX" +//! @param clevel z values at which to draw contours +//! @param nlevel Number of values in clevels +//! @param ixstart Index of first x coordinate to include in plot +//! @param ixn Number of x coordinates to include in plot +//! @param indexymin Array which specifies the min y index for each x +//! index in range ixstart, ixn. +//! @param indexymax Array which specifies the max y index for each x +//! coordinate (following the convention that the upper range limit is one more +//! than actual index limit) for an x index range of ixstart, ixn. +//-------------------------------------------------------------------------- + void plfplot3dcl( PLFLT *x, PLFLT *y, PLF2OPS zops, PLPointer zp, PLINT nx, PLINT ny, PLINT opt, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot:[11986] trunk/src/plot3d.c From: - 2011-10-20 08:55 ```Revision: 11986 http://plplot.svn.sourceforge.net/plplot/?rev=11986&view=rev Author: andrewross Date: 2011-10-20 08:55:17 +0000 (Thu, 20 Oct 2011) Log Message: ----------- Avoid using variable declaration in loop statements as this is a C99 feature, and generates errors with the standard gcc command line flags. Modified Paths: -------------- trunk/src/plot3d.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2011-10-20 04:35:53 UTC (rev 11985) +++ trunk/src/plot3d.c 2011-10-20 08:55:17 UTC (rev 11986) @@ -979,6 +979,7 @@ PLFLT ( *getz )( PLPointer, PLINT, PLINT ) = zops->get; PLFLT *_x = NULL, *_y = NULL, **_z = NULL; const PLFLT *x_modified, *y_modified; + int i; pl3mode = 0; @@ -1011,7 +1012,7 @@ // Check that points in x and in y are strictly increasing - for ( int i = 0; i < nx - 1; i++ ) + for ( i = 0; i < nx - 1; i++ ) { if ( x[i] >= x[i + 1] ) { @@ -1019,7 +1020,7 @@ return; } } - for ( int i = 0; i < ny - 1; i++ ) + for ( i = 0; i < ny - 1; i++ ) { if ( y[i] >= y[i + 1] ) { @@ -1309,7 +1310,7 @@ plAlloc2dGrid( &cgrid2.yg, nx, ny ); plAlloc2dGrid( &zstore, nx, ny ); - for ( int i = 0; i < nx; i++ ) + for ( i = 0; i < nx; i++ ) { for ( j = 0; j < ny; j++ ) { @@ -1444,7 +1445,7 @@ { free( _x ); free( _y ); - for ( int i = 0; i < nx; i++ ) + for ( i = 0; i < nx; i++ ) free( _z[i] ); free( _z ); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot:[11988] trunk/src/plot3d.c From: - 2011-10-20 14:11 ```Revision: 11988 http://plplot.svn.sourceforge.net/plplot/?rev=11988&view=rev Author: andrewross Date: 2011-10-20 14:11:41 +0000 (Thu, 20 Oct 2011) Log Message: ----------- Remove redefinitions of variables which shadow existing variables. Modified Paths: -------------- trunk/src/plot3d.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2011-10-20 12:49:06 UTC (rev 11987) +++ trunk/src/plot3d.c 2011-10-20 14:11:41 UTC (rev 11988) @@ -1064,7 +1064,7 @@ int _nx = ixmax - ixmin + 1; int _ny = iymax - iymin + 1; PLFLT ty0, ty1, tx0, tx1; - int i, j; + int j; if ( _nx <= 1 || _ny <= 1 ) { @@ -1338,7 +1338,7 @@ cline = clev->line; do // there are several lines that make up each contour { - int cx, i, k, l, m, start, end; + int cx, k, l, m, start, end; PLFLT tx, ty; if ( cline->npts > np ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```