From: <and...@us...> - 2011-08-04 09:07:51
|
Revision: 11853 http://plplot.svn.sourceforge.net/plplot/?rev=11853&view=rev Author: andrewross Date: 2011-08-04 09:07:44 +0000 (Thu, 04 Aug 2011) Log Message: ----------- Update java and D versions of example 27 to include new plarc demo. Modified Paths: -------------- trunk/examples/d/x27d.d trunk/examples/java/x27.java Modified: trunk/examples/d/x27d.d =================================================================== --- trunk/examples/d/x27d.d 2011-08-04 08:59:19 UTC (rev 11852) +++ trunk/examples/d/x27d.d 2011-08-04 09:07:44 UTC (rev 11853) @@ -101,6 +101,9 @@ spiro( params[i], fill ); } + // Finally, an example to test out plarc capabilities + arcs(); + plend(); return 0; } @@ -194,3 +197,33 @@ plline( xcoord, ycoord ); } } + +void arcs() { + const int NSEG = 8; + int i; + PLFLT theta, dtheta; + PLFLT a, b; + + theta = 0.0; + dtheta = 360.0 / NSEG; + plenv( -10.0, 10.0, -10.0, 10.0, 1, 0 ); + + // Plot segments of circle in different colors + for ( i = 0; i < NSEG; i++ ) { + plcol0( i%2 + 1 ); + plarc(0.0, 0.0, 8.0, 8.0, theta, theta + dtheta, 0.0, 0); + theta = theta + dtheta; + } + + // Draw several filled ellipses inside the circle at different + // angles. + a = 3.0; + b = a * tan( (dtheta/180.0*PI)/2.0 ); + theta = dtheta/2.0; + for ( i = 0; i < NSEG; i++ ) { + plcol0( 2 - i%2 ); + plarc( a*cos(theta/180.0*PI), a*sin(theta/180.0*PI), a, b, 0.0, 360.0, theta, 1); + theta = theta + dtheta; + } + +} Modified: trunk/examples/java/x27.java =================================================================== --- trunk/examples/java/x27.java 2011-08-04 08:59:19 UTC (rev 11852) +++ trunk/examples/java/x27.java 2011-08-04 09:07:44 UTC (rev 11853) @@ -112,7 +112,10 @@ pls.vpor( 0.0, 1.0, 0.0, 1.0 ); spiro( params[i], fill ); } - + + // Finally, an example to test out plarc capabilities + arcs(); + pls.end(); } @@ -212,6 +215,37 @@ else pls.line( xcoord, ycoord ); } + + void arcs() { + int NSEG = 8; + int i; + double theta, dtheta; + double a, b; + + theta = 0.0; + dtheta = 360.0 / NSEG; + pls.env( -10.0, 10.0, -10.0, 10.0, 1, 0 ); + + // Plot segments of circle in different colors + for ( i = 0; i < NSEG; i++ ) { + pls.col0( i%2 + 1 ); + pls.arc(0.0, 0.0, 8.0, 8.0, theta, theta + dtheta, 0.0, false); + theta = theta + dtheta; + } + + // Draw several filled ellipses inside the circle at different + // angles. + a = 3.0; + b = a * Math.tan( (dtheta/180.0*Math.PI)/2.0 ); + theta = dtheta/2.0; + for ( i = 0; i < NSEG; i++ ) { + pls.col0( 2 - i%2 ); + pls.arc( a*Math.cos(theta/180.0*Math.PI), a*Math.sin(theta/180.0*Math.PI), a, b, 0.0, 360.0, theta, true); + theta = theta + dtheta; + } + + } + } //-------------------------------------------------------------------------- This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |