Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## [Plplot-cvs] SF.net SVN: plplot: [7870] trunk/src

 [Plplot-cvs] SF.net SVN: plplot: [7870] trunk/src From: - 2007-09-18 00:47:42 ```Revision: 7870 http://plplot.svn.sourceforge.net/plplot/?rev=7870&view=rev Author: hbabcock Date: 2007-09-17 17:47:43 -0700 (Mon, 17 Sep 2007) Log Message: ----------- Changed the shear matrix used by plptex3 and plmtex3 to be of the same type as that used by plxytx() and plztx(). Modified Paths: -------------- trunk/src/plot3d.c trunk/src/plsym.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2007-09-17 04:15:10 UTC (rev 7869) +++ trunk/src/plot3d.c 2007-09-18 00:47:43 UTC (rev 7870) @@ -2369,6 +2369,14 @@ * void plRotationShear * * Calculates the rotation and shear angles from a plplot transformation matrix + * + * N.B. The plot transformation matrix is the product of the following + * rotation and shear matrices: + * + * [c(t) -s(t)] [1 s(p)] + * [s(t) c(t)] [0 c(p)] + * + * Where t is the rotation angle and phi is the shear angle. \*--------------------------------------------------------------------------*/ void @@ -2379,7 +2387,7 @@ *rotation = -*rotation; } - *shear = -atan(xFormMatrix[0]*xFormMatrix[1] + + *shear = -asin(xFormMatrix[0]*xFormMatrix[1] + xFormMatrix[2]*xFormMatrix[3]); } Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2007-09-17 04:15:10 UTC (rev 7869) +++ trunk/src/plsym.c 2007-09-18 00:47:43 UTC (rev 7870) @@ -1392,18 +1392,18 @@ if(plP_stindex(side, "v") != -1){ xform[0] = 0.0; - xform[1] = -1.0; + xform[1] = -cos(theta); xform[2] = 1.0; - xform[3] = -tan(theta); + xform[3] = -sin(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } // parallel, rotate & shear by angle else { xform[0] = cos(theta); - xform[1] = cos(theta)*tan(theta) - sin(theta); + xform[1] = 0.0; xform[2] = sin(theta); - xform[3] = sin(theta)*tan(theta) + cos(theta); + xform[3] = 1.0; plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1552,18 +1552,18 @@ if(plP_stindex(side, "v") != -1){ xform[0] = cos(theta); - xform[1] = cos(theta)*tan(theta) - sin(theta); + xform[1] = 0.0; xform[2] = sin(theta); - xform[3] = sin(theta)*tan(theta) + cos(theta); + xform[3] = 1.0; plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } else { xform[0] = 0.0; - xform[1] = -1.0; + xform[1] = -cos(theta); xform[2] = 1.0; - xform[3] = -tan(theta); + xform[3] = -sin(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1654,9 +1654,9 @@ // compute the transform xform[0] = cos(theta); - xform[1] = cos(theta) * tan(phi) - sin(theta); + xform[1] = cos(theta) * sin(phi) - sin(theta) * cos(phi); xform[2] = sin(theta); - xform[3] = sin(theta) * tan(phi) + cos(theta); + xform[3] = sin(theta) * sin(phi) + cos(theta) * cos(phi); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```

 [Plplot-cvs] SF.net SVN: plplot: [7869] trunk/src From: - 2007-09-17 04:15:07 ```Revision: 7869 http://plplot.svn.sourceforge.net/plplot/?rev=7869&view=rev Author: hbabcock Date: 2007-09-16 21:15:10 -0700 (Sun, 16 Sep 2007) Log Message: ----------- Fix a mistake in calculating tranformation matrices in plptex3 and plmtex3. Sin(shear angle) was being used when tan(shear angle) is correct. Modified Paths: -------------- trunk/src/plot3d.c trunk/src/plsym.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2007-09-17 01:24:44 UTC (rev 7868) +++ trunk/src/plot3d.c 2007-09-17 04:15:10 UTC (rev 7869) @@ -2379,7 +2379,7 @@ *rotation = -*rotation; } - *shear = -asin(xFormMatrix[0]*xFormMatrix[1] + + *shear = -atan(xFormMatrix[0]*xFormMatrix[1] + xFormMatrix[2]*xFormMatrix[3]); } Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2007-09-17 01:24:44 UTC (rev 7868) +++ trunk/src/plsym.c 2007-09-17 04:15:10 UTC (rev 7869) @@ -1394,16 +1394,16 @@ xform[0] = 0.0; xform[1] = -1.0; xform[2] = 1.0; - xform[3] = -sin(theta); + xform[3] = -tan(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } // parallel, rotate & shear by angle else { xform[0] = cos(theta); - xform[1] = cos(theta)*sin(theta) - sin(theta); + xform[1] = cos(theta)*tan(theta) - sin(theta); xform[2] = sin(theta); - xform[3] = sin(theta)*sin(theta) + cos(theta); + xform[3] = sin(theta)*tan(theta) + cos(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1552,9 +1552,9 @@ if(plP_stindex(side, "v") != -1){ xform[0] = cos(theta); - xform[1] = cos(theta)*sin(theta) - sin(theta); + xform[1] = cos(theta)*tan(theta) - sin(theta); xform[2] = sin(theta); - xform[3] = sin(theta)*sin(theta) + cos(theta); + xform[3] = sin(theta)*tan(theta) + cos(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1563,7 +1563,7 @@ xform[0] = 0.0; xform[1] = -1.0; xform[2] = 1.0; - xform[3] = -sin(theta); + xform[3] = -tan(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1654,10 +1654,10 @@ // compute the transform xform[0] = cos(theta); - xform[1] = cos(theta) * sin(phi) - sin(theta); + xform[1] = cos(theta) * tan(phi) - sin(theta); xform[2] = sin(theta); - xform[3] = sin(theta) * sin(phi) + cos(theta); - + xform[3] = sin(theta) * tan(phi) + cos(theta); + plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot: [7870] trunk/src From: - 2007-09-18 00:47:42 ```Revision: 7870 http://plplot.svn.sourceforge.net/plplot/?rev=7870&view=rev Author: hbabcock Date: 2007-09-17 17:47:43 -0700 (Mon, 17 Sep 2007) Log Message: ----------- Changed the shear matrix used by plptex3 and plmtex3 to be of the same type as that used by plxytx() and plztx(). Modified Paths: -------------- trunk/src/plot3d.c trunk/src/plsym.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2007-09-17 04:15:10 UTC (rev 7869) +++ trunk/src/plot3d.c 2007-09-18 00:47:43 UTC (rev 7870) @@ -2369,6 +2369,14 @@ * void plRotationShear * * Calculates the rotation and shear angles from a plplot transformation matrix + * + * N.B. The plot transformation matrix is the product of the following + * rotation and shear matrices: + * + * [c(t) -s(t)] [1 s(p)] + * [s(t) c(t)] [0 c(p)] + * + * Where t is the rotation angle and phi is the shear angle. \*--------------------------------------------------------------------------*/ void @@ -2379,7 +2387,7 @@ *rotation = -*rotation; } - *shear = -atan(xFormMatrix[0]*xFormMatrix[1] + + *shear = -asin(xFormMatrix[0]*xFormMatrix[1] + xFormMatrix[2]*xFormMatrix[3]); } Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2007-09-17 04:15:10 UTC (rev 7869) +++ trunk/src/plsym.c 2007-09-18 00:47:43 UTC (rev 7870) @@ -1392,18 +1392,18 @@ if(plP_stindex(side, "v") != -1){ xform[0] = 0.0; - xform[1] = -1.0; + xform[1] = -cos(theta); xform[2] = 1.0; - xform[3] = -tan(theta); + xform[3] = -sin(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } // parallel, rotate & shear by angle else { xform[0] = cos(theta); - xform[1] = cos(theta)*tan(theta) - sin(theta); + xform[1] = 0.0; xform[2] = sin(theta); - xform[3] = sin(theta)*tan(theta) + cos(theta); + xform[3] = 1.0; plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1552,18 +1552,18 @@ if(plP_stindex(side, "v") != -1){ xform[0] = cos(theta); - xform[1] = cos(theta)*tan(theta) - sin(theta); + xform[1] = 0.0; xform[2] = sin(theta); - xform[3] = sin(theta)*tan(theta) + cos(theta); + xform[3] = 1.0; plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } else { xform[0] = 0.0; - xform[1] = -1.0; + xform[1] = -cos(theta); xform[2] = 1.0; - xform[3] = -tan(theta); + xform[3] = -sin(theta); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } @@ -1654,9 +1654,9 @@ // compute the transform xform[0] = cos(theta); - xform[1] = cos(theta) * tan(phi) - sin(theta); + xform[1] = cos(theta) * sin(phi) - sin(theta) * cos(phi); xform[2] = sin(theta); - xform[3] = sin(theta) * tan(phi) + cos(theta); + xform[3] = sin(theta) * sin(phi) + cos(theta) * cos(phi); plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot: [7876] trunk/src From: - 2007-09-20 01:51:15 ```Revision: 7876 http://plplot.svn.sourceforge.net/plplot/?rev=7876&view=rev Author: hbabcock Date: 2007-09-19 18:51:19 -0700 (Wed, 19 Sep 2007) Log Message: ----------- Fixed quadrant 3/4 problem in plptex3 and plRotationShear. Modified Paths: -------------- trunk/src/plot3d.c trunk/src/plsym.c Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2007-09-19 01:28:00 UTC (rev 7875) +++ trunk/src/plot3d.c 2007-09-20 01:51:19 UTC (rev 7876) @@ -2388,6 +2388,14 @@ } *shear = -asin(xFormMatrix[0]*xFormMatrix[1] + - xFormMatrix[2]*xFormMatrix[3]); + xFormMatrix[2]*xFormMatrix[3]); + + // 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); + } } Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2007-09-19 01:28:00 UTC (rev 7875) +++ trunk/src/plsym.c 2007-09-20 01:51:19 UTC (rev 7876) @@ -1619,12 +1619,10 @@ // // Compute the dot product of the vector d and the vector s to // determine the angle between them (acos(t) = d . s / |d| |s|). - // Then, because the vector s could go "down" from the text - // baseline rather than "up", compute the cross product and - // if this is negative use 180 minus the angle instead, as this - // is the angle between the "up" vector and the text baseline. - // Finally we subtract the angle from 90 as shear is specified - // relative to a line that is perpendicular to the text baseline. + // Then because acos will return a number from 0.0 to PI, i.e. + // only in quadrants 1 or 2, compute the cross product of the + // two vectors. If this is negative then the angle is adjusted + // 0.0 to -PI. if((sx == 0.0) && (sy == 0.0) && (sz == 0.0)){ phi = 0.0; @@ -1635,7 +1633,7 @@ ls = sqrt((xpc - xspc) * (xpc - xspc) + (ypc - yspc) * (ypc - yspc)); phi = acos(((xdpc - xpc) * (xspc - xpc) + (ydpc - ypc) * (yspc - ypc))/(ld * ls)); cp = (xdpc - xpc) * (yspc - ypc) - (ydpc - ypc) * (xspc - xpc); - if(cp < 0.0){ phi = 3.14159 - phi; } + if(cp < 0.0){ phi = -phi; } phi = 1.570796 - phi; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot: [8373] trunk/src From: - 2008-04-15 21:24:07 ```Revision: 8373 http://plplot.svn.sourceforge.net/plplot/?rev=8373&view=rev Author: andrewross Date: 2008-04-15 14:24:07 -0700 (Tue, 15 Apr 2008) Log Message: ----------- Cosmetic fix to remove C++ // style comments from the main src directory. Modified Paths: -------------- trunk/src/plimage.c trunk/src/plot3d.c trunk/src/plsym.c Modified: trunk/src/plimage.c =================================================================== --- trunk/src/plimage.c 2008-04-15 09:46:53 UTC (rev 8372) +++ trunk/src/plimage.c 2008-04-15 21:24:07 UTC (rev 8373) @@ -179,12 +179,12 @@ { PLINT nnx, nny, ix, iy, ixx, iyy, xm, ym; PLFLT dx, dy; - // Zf holds transformed image pixel values - // szmin and szmax are zmin and zmax scaled to unsigned short values + /* Zf holds transformed image pixel values + * szmin and szmax are zmin and zmax scaled to unsigned short values */ unsigned short *Zf, szmin, szmax; short *Xf, *Yf; - // This is used when looping through the image array, checking to - // make sure the values are within an acceptable range. + /* This is used when looping through the image array, checking to + * make sure the values are within an acceptable range. */ PLFLT datum; if (plsc->level < 3) { @@ -214,10 +214,10 @@ xm = floor((Dxmin-xmin)/dx); ym = floor((Dymin-ymin)/dy); - // Go through the image values and scale them to fit in an - // unsigned short range. - // Any values greater than valuemax are set to valuemax, - // and values less than valuemin are set to valuemin. + /* Go through the image values and scale them to fit in an + * unsigned short range. + * Any values greater than valuemax are set to valuemax, + * and values less than valuemin are set to valuemin. */ ixx=-1; for (ix=xm; ix color range mapped to the minimum - // and maximum values in idata. + /* Call plimagefr with the value -> color range mapped to the minimum + * and maximum values in idata. */ plimagefr(idata, nx, ny, xmin, xmax, ymin, ymax, zmin, zmax, Dxmin, Dxmax, Dymin, Dymax, data_min, data_max); } Modified: trunk/src/plot3d.c =================================================================== --- trunk/src/plot3d.c 2008-04-15 09:46:53 UTC (rev 8372) +++ trunk/src/plot3d.c 2008-04-15 21:24:07 UTC (rev 8373) @@ -2390,9 +2390,9 @@ *shear = -asin(xFormMatrix[0]*xFormMatrix[1] + xFormMatrix[2]*xFormMatrix[3]); - // 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. + /* 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); Modified: trunk/src/plsym.c =================================================================== --- trunk/src/plsym.c 2008-04-15 09:46:53 UTC (rev 8372) +++ trunk/src/plsym.c 2008-04-15 21:24:07 UTC (rev 8373) @@ -1269,36 +1269,36 @@ void c_plmtex3(const char *side, PLFLT disp, PLFLT pos, PLFLT just, const char *text) { - // local storage + /* local storage */ PLFLT xmin, xmax, ymin, ymax, zmin, zmax, zscale; PLFLT chrdef, chrht; - // calculated + /* calculated */ PLFLT xpc, ypc, xrefpc, yrefpc; PLFLT epx1, epy1, epx2, epy2, epx3, epy3; PLFLT dispx, dispy, xform[4]; PLFLT shift, theta, temp; - // check that the plotting environment is set up + /* check that the plotting environment is set up */ if (plsc->level < 3) { plabort("plmtex3: Please set up window first"); return; } - // get plotting environment information + /* get plotting environment information */ plP_gdom(&xmin, &xmax, &ymin, &ymax); plP_grange(&zscale, &zmin, &zmax); plgchr(&chrdef, &chrht); - // handle x/y axises + /* handle x/y axises */ if((plP_stindex(side, "x") != -1)||(plP_stindex(side, "y") != -1)){ - // get the locations of the end points of the relevant axis + /* get the locations of the end points of the relevant axis */ - // x axis label + /* x axis label */ if(plP_stindex(side, "x") != -1){ - // primary + /* primary */ if(plP_stindex(side, "p") != -1){ epx1 = plP_wcpcx(plP_w3wcx(xmin, ymin, zmin)); epy1 = plP_wcpcy(plP_w3wcy(xmin, ymin, zmin)); @@ -1325,7 +1325,7 @@ } } - // text always goes from left to right + /* text always goes from left to right */ if(epx1 > epx2){ temp = epx1; epx1 = epx2; @@ -1333,15 +1333,15 @@ temp = epy1; epy1 = epy2; epy2 = temp; - // recalculate position assuming the user specified - // it in the min -> max direction of the axis. + /* recalculate position assuming the user specified + * it in the min -> max direction of the axis. */ pos = 1.0 - pos; } - // calculate location of text center point + /* calculate location of text center point */ - // 1. calculate the angle of the axis we are to - // draw the text on relative to the horizontal + /* 1. calculate the angle of the axis we are to + * draw the text on relative to the horizontal */ if((epx2-epx1)!=0.0){ theta = atan((epy2 - epy1)/(epx2 - epx1)); @@ -1353,22 +1353,22 @@ } } - // 2. calculate the perpendicular vector + /* 2. calculate the perpendicular vector */ dispy = disp * chrht; - // 3. calculate x & y center points + /* 3. calculate x & y center points */ xpc = pos * (epx2 - epx1) + epx1; ypc = pos * (epy2 - epy1) + epy1; - // 4. compute reference point - // It appears that drivers that cannot handle text justification - // use this as the starting point of the string. - // Calculations must be done in millimeters for this part - // so we convert to mm, do the calculation and convert back. - // The calculation is also dependent of the orientation - // (perpendicular or parallel) of the text. + /* 4. compute reference point + * It appears that drivers that cannot handle text justification + * use this as the starting point of the string. + * Calculations must be done in millimeters for this part + * so we convert to mm, do the calculation and convert back. + * The calculation is also dependent of the orientation + * (perpendicular or parallel) of the text. */ xpc = plP_dcmmx(plP_pcdcx(xpc)); ypc = plP_dcmmy(plP_pcdcy(ypc)) - dispy; @@ -1388,9 +1388,9 @@ xrefpc = plP_mmpcx(xrefpc); yrefpc = plP_mmpcy(yrefpc); - // 5. compute transform matrix & draw text + /* 5. compute transform matrix & draw text */ - // perpendicular, rotate 90 degrees & shear + /* perpendicular, rotate 90 degrees & shear */ if(plP_stindex(side, "v") != -1){ xform[0] = 0.0; @@ -1400,7 +1400,7 @@ plP_text(0, just, xform, xpc, ypc, xrefpc, yrefpc, text); } - // parallel, rotate & shear by angle + /* parallel, rotate & shear by angle */ else { xform[0] = cos(theta); xform[1] = 0.0; @@ -1411,13 +1411,13 @@ } } - // handle z axises + /* handle z axises */ if(plP_stindex(side, "z") != -1){ - // Find the left most of the 4 z axis options for "primary" - // Also find the location of frontmost point in the graph, - // which will be needed to calculate at what angle to shear - // the text. + /* Find the left most of the 4 z axis options for "primary" + * Also find the location of frontmost point in the graph, + * which will be needed to calculate at what angle to shear + * the text. */ if(plP_stindex(side, "p") != -1){ @@ -1452,7 +1452,7 @@ } } - // find the right most of the 4 z axis options for "primary" + /* find the right most of the 4 z axis options for "primary" */ if(plP_stindex(side, "s") != -1){ epx1 = plP_wcpcx(plP_w3wcx(xmin, ymin, zmin)); @@ -1486,15 +1486,15 @@ } } - // Calculate location of text center point. - // This is very similiar for the z axis. + /* Calculate location of text center point. + * This is very similiar for the z axis. */ - // primary and secondary have to be handled separately here + /* primary and secondary have to be handled separately here */ if(plP_stindex(side, "p") != -1){ - // 1. Calculate the angle of the axis we are to - // draw the text on relative to the horizontal. + /* 1. Calculate the angle of the axis we are to + * draw the text on relative to the horizontal. */ if((epx3-epx1)!=0.0){ theta = atan((epy3 - epy1)/(epx3 - epx1)); @@ -1506,7 +1506,7 @@ } } - // 2. Calculate the perpendicular vector. + /* 2. Calculate the perpendicular vector. */ dispx = -cos(theta) * disp * chrht; dispy = -sin(theta) * disp * chrht; @@ -1525,12 +1525,12 @@ dispy = sin(theta) * disp * chrht; } - // 3. Calculate x & y center points. + /* 3. Calculate x & y center points. */ xpc = epx1; ypc = pos * (epy2 - epy1) + epy1; - // 4. Compute the reference point. + /* 4. Compute the reference point. */ xpc = plP_dcmmx(plP_pcdcx(xpc)) + dispx; ypc = plP_dcmmy(plP_pcdcy(ypc)) + dispy; @@ -1550,7 +1550,7 @@ xrefpc = plP_mmpcx(xrefpc); yrefpc = plP_mmpcy(yrefpc); - // 5. Compute transform matrix & draw text. + /* 5. Compute transform matrix & draw text. */ if(plP_stindex(side, "v") != -1){ xform[0] = cos(theta); @@ -1601,30 +1601,30 @@ PLFLT xpc, ypc, xrefpc, yrefpc, xdpc, ydpc, xspc, yspc, ld, ls, cp, shift; PLFLT theta, phi, xform[4]; - // check that the plotting environment is set up + /* check that the plotting environment is set up */ if (plsc->level < 3) { plabort("plptex3: Please set up window first"); return; } - // compute text x,y location in physical coordinates + /* compute text x,y location in physical coordinates */ xpc = plP_wcpcx(plP_w3wcx(wx, wy, wz)); ypc = plP_wcpcy(plP_w3wcy(wx, wy, wz)); - // determine angle to rotate text in the x-y plane + /* determine angle to rotate text in the x-y plane */ xdpc = plP_wcpcx(plP_w3wcx(wx+dx, wy+dy, wz+dz)); ydpc = plP_wcpcy(plP_w3wcy(wx+dx, wy+dy, wz+dz)); theta = atan2(ydpc - ypc, xdpc - xpc); - // Determine angle to shear text in the x-y plane. This is a little - // messy, but basically the idea is: - // - // Compute the dot product of the vector d and the vector s to - // determine the angle between them (acos(t) = d . s / |d| |s|). - // Then because acos will return a number from 0.0 to PI, i.e. - // only in quadrants 1 or 2, compute the cross product of the - // two vectors. If this is negative then the angle is adjusted - // 0.0 to -PI. + /* Determine angle to shear text in the x-y plane. This is a little + * messy, but basically the idea is: + * + * Compute the dot product of the vector d and the vector s to + * determine the angle between them (acos(t) = d . s / |d| |s|). + * Then because acos will return a number from 0.0 to PI, i.e. + * only in quadrants 1 or 2, compute the cross product of the + * two vectors. If this is negative then the angle is adjusted + * 0.0 to -PI. */ if((sx == 0.0) && (sy == 0.0) && (sz == 0.0)){ phi = 0.0; @@ -1639,7 +1639,7 @@ phi = 1.570796 - phi; } - // compute the reference point + /* compute the reference point */ xpc = plP_dcmmx(plP_pcdcx(xpc)); ypc = plP_dcmmy(plP_pcdcy(ypc)); @@ -1652,7 +1652,7 @@ xrefpc = plP_mmpcx(xrefpc); yrefpc = plP_mmpcy(yrefpc); - // compute the transform + /* compute the transform */ xform[0] = cos(theta); xform[1] = cos(theta) * sin(phi) - sin(theta) * cos(phi); xform[2] = sin(theta); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot: [8481] trunk/src From: - 2008-06-20 14:06:46 ```Revision: 8481 http://plplot.svn.sourceforge.net/plplot/?rev=8481&view=rev Author: smekal Date: 2008-06-20 07:06:49 -0700 (Fri, 20 Jun 2008) Log Message: ----------- Changes to driver options, which are now discarded right after the initialization of the driver. Removed the call plP_FreeDrvOpts in c_plend(), since the options are already freed at this point. Fixed also a memory leak - if only one driver option was set, the memory for the option string and the value weren't freed. Modified Paths: -------------- trunk/src/plargs.c trunk/src/plcore.c Modified: trunk/src/plargs.c =================================================================== --- trunk/src/plargs.c 2008-06-16 15:27:05 UTC (rev 8480) +++ trunk/src/plargs.c 2008-06-20 14:06:49 UTC (rev 8481) @@ -1307,9 +1307,6 @@ plP_FreeDrvOpts() { DrvOptCmd *drvp, *drvpl; - if (!drv_opt.next) - return; - drvp = &drv_opt; do { drvpl = drvp; @@ -1717,10 +1714,6 @@ if (value == NULL) plexit("opt_drvopt: Out of memory!?"); - /* first release allocated memory from a (possible) former call - of opt_drvopt() */ - plP_FreeDrvOpts(); - drvp = &drv_opt; *option = *value = '\0'; tt = option; Modified: trunk/src/plcore.c =================================================================== --- trunk/src/plcore.c 2008-06-16 15:27:05 UTC (rev 8480) +++ trunk/src/plcore.c 2008-06-20 14:06:49 UTC (rev 8481) @@ -1647,6 +1647,15 @@ plP_bop(); plsc->level = 1; + +/* The driver options are freed after driver initialisation, + * since it is assumed that in this function options are + * processed and stored somewhere else. For further driver + * initialisations (e.g. copy stream) there are no driver + * options defined. */ + + plP_FreeDrvOpts(); + /* Calculate factor such that the character aspect ratio is preserved * when the overall aspect ratio is changed, i.e., if portrait mode is * requested (only honored for subset of drivers) or if the aspect ratio @@ -1782,8 +1791,6 @@ } free_mem(dispatch_table); - plP_FreeDrvOpts(); - lib_initialized = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot: [8487] trunk/src From: - 2008-06-25 08:36:33 ```Revision: 8487 http://plplot.svn.sourceforge.net/plplot/?rev=8487&view=rev Author: smekal Date: 2008-06-25 01:36:42 -0700 (Wed, 25 Jun 2008) Log Message: ----------- Added dummy functions in case if snprintf is not available. Replaced sprintf calls in plargs.c. Modified Paths: -------------- trunk/src/plargs.c trunk/src/plctrl.c Modified: trunk/src/plargs.c =================================================================== --- trunk/src/plargs.c 2008-06-25 08:34:48 UTC (rev 8486) +++ trunk/src/plargs.c 2008-06-25 08:36:42 UTC (rev 8487) @@ -1224,7 +1224,8 @@ DrvOpt *t; int fl; char msg[80]; - + memset( msg, '\0', sizeof(msg) ); + if (!drv_opt.option) return 1; @@ -1245,7 +1246,7 @@ case DRV_INT: if (sscanf(drvp->value, "%d", (int *)t->var_ptr) != 1) { - sprintf(msg,"Incorrect argument to '%s' option", drvp->option); + snprintf(msg, sizeof(msg)-1, "Incorrect argument to '%s' option", drvp->option); plexit(msg); } #ifdef DEBUG @@ -1255,7 +1256,7 @@ case DRV_FLT: if (sscanf(drvp->value, "%f", (float *)t->var_ptr) != 1) { - sprintf(msg,"Incorrect argument to '%s' option", drvp->option); + snprintf(msg, sizeof(msg)-1, "Incorrect argument to '%s' option", drvp->option); plexit(msg); } #ifdef DEBUG @@ -1268,7 +1269,7 @@ } if (!fl) { - sprintf(msg, "Option '%s' not recognized.\n\nRecognized options for this driver are:\n", drvp->option); + snprintf(msg, sizeof(msg)-1, "Option '%s' not recognized.\n\nRecognized options for this driver are:\n", drvp->option); plwarn(msg); plHelpDrvOpts(acc_opt); plexit(""); Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2008-06-25 08:34:48 UTC (rev 8486) +++ trunk/src/plctrl.c 2008-06-25 08:36:42 UTC (rev 8487) @@ -2101,3 +2101,48 @@ return dest; } + +#ifndef HAVE_SNPRINTF +/*--------------------------------------------------------------------------*\ + * plsnprintf() + * + * Dummy function for snprintf(). This function just calls + * the unsafe function ignoring the string size. This function will + * rarely be needed if ever. +\*--------------------------------------------------------------------------*/ + +int +plsnprintf(char *buffer, int n, const char *format, ...) +{ + int ret; + + va_list args; + va_start(args, format); + ret=vsprintf(buffer, fmt, args); + va_end( argptr ); + + return ret; +} + +/*--------------------------------------------------------------------------*\ + * plsnscanf() + * + * Dummy function for snscanf(). This function just calls + * the unsafe function ignoring the string size. This function will + * rarely be needed if ever. +\*--------------------------------------------------------------------------*/ + +int +plsnscanf( const char *buffer, int n, const char *format, ... ) +{ + int ret; + + va_list argptr; + va_start(argptr, format); + ret=vsscanf(buffer, fmt, args); + va_end(argptr); + + return ret; +} + +#endif /* HAVE_SNPRINTF */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```
 [Plplot-cvs] SF.net SVN: plplot: [8508] trunk/src From: - 2008-07-07 09:18:51 ```Revision: 8508 http://plplot.svn.sourceforge.net/plplot/?rev=8508&view=rev Author: smekal Date: 2008-07-07 02:18:59 -0700 (Mon, 07 Jul 2008) Log Message: ----------- Added code for Mersenne Twister (random number generator, RNG) to the src directory and changed CMakeLists.txt accordingly. Added new function definitions to plctrl.c (plseed, plrandd, plrandi) which provide an interface to this RNG. RNG can be easily replaced by some other code. Modified Paths: -------------- trunk/src/CMakeLists.txt trunk/src/plctrl.c Added Paths: ----------- trunk/src/mt19937ar.c trunk/src/mt19937ar.h Modified: trunk/src/CMakeLists.txt =================================================================== --- trunk/src/CMakeLists.txt 2008-07-07 09:14:25 UTC (rev 8507) +++ trunk/src/CMakeLists.txt 2008-07-07 09:18:59 UTC (rev 8508) @@ -48,6 +48,7 @@ plbuf.c plgridd.c plvect.c +mt19937ar.c ) if(WIN32 AND BUILD_SHARED_LIBS) Added: trunk/src/mt19937ar.c =================================================================== --- trunk/src/mt19937ar.c (rev 0) +++ trunk/src/mt19937ar.c 2008-07-07 09:18:59 UTC (rev 8508) @@ -0,0 +1,175 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + Copyright (C) 2005, Mutsuo Saito, + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) +*/ + +#include +#include "mt19937ar.h" + +/* Period parameters */ +#define N 624 +#define M 397 +#define MATRIX_A 0x9908b0dfUL /* constant vector a */ +#define UPPER_MASK 0x80000000UL /* most significant w-r bits */ +#define LOWER_MASK 0x7fffffffUL /* least significant r bits */ + +static unsigned long mt[N]; /* the array for the state vector */ +static int mti=N+1; /* mti==N+1 means mt[N] is not initialized */ + +/* initializes mt[N] with a seed */ +void init_genrand(unsigned long s) +{ + mt[0]= s & 0xffffffffUL; + for (mti=1; mti> 30)) + mti); + /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ + /* In the previous versions, MSBs of the seed affect */ + /* only MSBs of the array mt[]. */ + /* 2002/01/09 modified by Makoto Matsumoto */ + mt[mti] &= 0xffffffffUL; + /* for >32 bit machines */ + } +} + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +/* slight change for C++, 2004/2/26 */ +void init_by_array(unsigned long init_key[], int key_length) +{ + int i, j, k; + init_genrand(19650218UL); + i=1; j=0; + k = (N>key_length ? N : key_length); + for (; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1664525UL)) + + init_key[j] + j; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; j++; + if (i>=N) { mt[0] = mt[N-1]; i=1; } + if (j>=key_length) j=0; + } + for (k=N-1; k; k--) { + mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 30)) * 1566083941UL)) + - i; /* non linear */ + mt[i] &= 0xffffffffUL; /* for WORDSIZE > 32 machines */ + i++; + if (i>=N) { mt[0] = mt[N-1]; i=1; } + } + + mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ +} + +/* generates a random number on [0,0xffffffff]-interval */ +unsigned long genrand_int32(void) +{ + unsigned long y; + static unsigned long mag01[2]={0x0UL, MATRIX_A}; + /* mag01[x] = x * MATRIX_A for x=0,1 */ + + if (mti >= N) { /* generate N words at one time */ + int kk; + + if (mti == N+1) /* if init_genrand() has not been called, */ + init_genrand(5489UL); /* a default initial seed is used */ + + for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; + } + for (;kk> 1) ^ mag01[y & 0x1UL]; + } + y = (mt[N-1]&UPPER_MASK)|(mt[0]&LOWER_MASK); + mt[N-1] = mt[M-1] ^ (y >> 1) ^ mag01[y & 0x1UL]; + + mti = 0; + } + + y = mt[mti++]; + + /* Tempering */ + y ^= (y >> 11); + y ^= (y << 7) & 0x9d2c5680UL; + y ^= (y << 15) & 0xefc60000UL; + y ^= (y >> 18); + + return y; +} + +/* generates a random number on [0,0x7fffffff]-interval */ +long genrand_int31(void) +{ + return (long)(genrand_int32()>>1); +} + +/* generates a random number on [0,1]-real-interval */ +double genrand_real1(void) +{ + return genrand_int32()*(1.0/4294967295.0); + /* divided by 2^32-1 */ +} + +/* generates a random number on [0,1)-real-interval */ +double genrand_real2(void) +{ + return genrand_int32()*(1.0/4294967296.0); + /* divided by 2^32 */ +} + +/* generates a random number on (0,1)-real-interval */ +double genrand_real3(void) +{ + return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); + /* divided by 2^32 */ +} + +/* generates a random number on [0,1) with 53-bit resolution*/ +double genrand_res53(void) +{ + unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; + return(a*67108864.0+b)*(1.0/9007199254740992.0); +} +/* These real versions are due to Isaku Wada, 2002/01/09 added */ Property changes on: trunk/src/mt19937ar.c ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Added: trunk/src/mt19937ar.h =================================================================== --- trunk/src/mt19937ar.h (rev 0) +++ trunk/src/mt19937ar.h 2008-07-07 09:18:59 UTC (rev 8508) @@ -0,0 +1,72 @@ +/* + A C-program for MT19937, with initialization improved 2002/1/26. + Coded by Takuji Nishimura and Makoto Matsumoto. + + Before using, initialize the state by using init_genrand(seed) + or init_by_array(init_key, key_length). + + Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, + All rights reserved. + Copyright (C) 2005, Mutsuo Saito + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + 3. The names of its contributors may not be used to endorse or promote + products derived from this software without specific prior written + permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + Any feedback is very welcome. + http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html + email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space) +*/ + +/* initializes mt[N] with a seed */ +void init_genrand(unsigned long s); + +/* initialize by an array with array-length */ +/* init_key is the array for initializing keys */ +/* key_length is its length */ +/* slight change for C++, 2004/2/26 */ +void init_by_array(unsigned long init_key[], int key_length); + +/* generates a random number on [0,0xffffffff]-interval */ +unsigned long genrand_int32(void); + +/* generates a random number on [0,0x7fffffff]-interval */ +long genrand_int31(void); + +/* These real versions are due to Isaku Wada, 2002/01/09 added */ +/* generates a random number on [0,1]-real-interval */ +double genrand_real1(void); + +/* generates a random number on [0,1)-real-interval */ +double genrand_real2(void); + +/* generates a random number on (0,1)-real-interval */ +double genrand_real3(void); + +/* generates a random number on [0,1) with 53-bit resolution*/ +double genrand_res53(void); Property changes on: trunk/src/mt19937ar.h ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + native Modified: trunk/src/plctrl.c =================================================================== --- trunk/src/plctrl.c 2008-07-07 09:14:25 UTC (rev 8507) +++ trunk/src/plctrl.c 2008-07-07 09:18:59 UTC (rev 8508) @@ -50,6 +50,9 @@ #include #endif +/* Random number generator (Mersenne Twister) */ +#include "mt19937ar.h" + /* Static functions */ /* Used by any external init code to suggest a path */ @@ -2146,3 +2149,39 @@ } #endif /* PL_HAVE_SNPRINTF */ + +/*--------------------------------------------------------------------------*\ + * plseed() + * + * Set the seed for the random number generator included. +\*--------------------------------------------------------------------------*/ + +void +c_plseed(unsigned int s) +{ + init_genrand(s); +} + +/*--------------------------------------------------------------------------*\ + * plrandi() + * + * Returns a random number on [0,0xffffffff]-interval. +\*--------------------------------------------------------------------------*/ + +unsigned long +c_plrandi(void) +{ + return genrand_int32(); +} + +/*--------------------------------------------------------------------------*\ + * plrandd() + * + * Returns a random number on [0,1]-interval. +\*--------------------------------------------------------------------------*/ + +PLFLT +c_plrandd(void) +{ + return (PLFLT)(genrand_real1()); +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ```