From: <and...@us...> - 2011-08-05 08:38:45
|
Revision: 11859 http://plplot.svn.sourceforge.net/plplot/?rev=11859&view=rev Author: andrewross Date: 2011-08-05 08:38:34 +0000 (Fri, 05 Aug 2011) Log Message: ----------- Update tcl and python versions of example 27 to include plarc demo. Modified Paths: -------------- trunk/examples/python/xw27.py trunk/examples/tcl/x27.tcl Modified: trunk/examples/python/xw27.py =================================================================== --- trunk/examples/python/xw27.py 2011-08-05 07:45:34 UTC (rev 11858) +++ trunk/examples/python/xw27.py 2011-08-05 08:38:34 UTC (rev 11859) @@ -79,6 +79,8 @@ plvpor( 0.0, 1.0, 0.0, 1.0 ) spiro( params[i], 1 ) + arcs() + def gcd(a, b): if not (type(a) is types.IntType and type(b) is types.IntType): raise RuntimeError, "gcd arguments must be integers" @@ -125,4 +127,30 @@ else: plline( xcoord, ycoord ) +def arcs() : + NSEG = 8 + + 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 in range (NSEG) : + 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 in range(NSEG): + 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 + + + main() Modified: trunk/examples/tcl/x27.tcl =================================================================== --- trunk/examples/tcl/x27.tcl 2011-08-05 07:45:34 UTC (rev 11858) +++ trunk/examples/tcl/x27.tcl 2011-08-05 08:38:34 UTC (rev 11859) @@ -81,6 +81,8 @@ $w cmd plvpor 0.0 1.0 0.0 1.0 spiro $w [lindex $params $i] $fill } + + arcs $w } #-------------------------------------------------------------------------- @@ -165,3 +167,31 @@ $w cmd plline $n xcoord ycoord } } + +proc arcs {w} { + set NSEG 8 + set pi $::PLPLOT::PL_PI + + set theta 0.0 + set dtheta [expr {360.0 / $NSEG}] + $w cmd plenv -10.0 10.0 -10.0 10.0 1 0 + + # Plot segments of circle in different colors + for { set i 0 } { $i < $NSEG } {incr i} { + $w cmd plcol0 [expr {$i%2 + 1}] + $w cmd plarc 0.0 0.0 8.0 8.0 $theta [expr {$theta + $dtheta}] 0.0 0 + set theta [expr {$theta + $dtheta}] + } + + # Draw several filled ellipses inside the circle at different + # angles. + set a 3.0 + set b [expr {$a * tan( ($dtheta/180.0*$pi)/2.0 )}] + set theta [expr {$dtheta/2.0}] + for {set i 0} { $i < $NSEG } { incr i } { + $w cmd plcol0 [expr {2 - $i%2}] + $w cmd plarc [expr {$a*cos($theta/180.0*$pi)}] [expr {$a*sin($theta/180.0*$pi)}] $a $b 0.0 360.0 $theta 1 + set theta [expr {$theta + $dtheta}] + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |