|
From: <and...@us...> - 2008-08-13 13:25:24
|
Revision: 8640
http://plplot.svn.sourceforge.net/plplot/?rev=8640&view=rev
Author: andrewross
Date: 2008-08-13 13:25:33 +0000 (Wed, 13 Aug 2008)
Log Message:
-----------
Add python version of example 27.
Modified Paths:
--------------
trunk/examples/python/CMakeLists.txt
trunk/plplot_test/test_python.sh.in
Added Paths:
-----------
trunk/examples/python/x27
trunk/examples/python/xw27.py
Modified: trunk/examples/python/CMakeLists.txt
===================================================================
--- trunk/examples/python/CMakeLists.txt 2008-08-13 12:32:08 UTC (rev 8639)
+++ trunk/examples/python/CMakeLists.txt 2008-08-13 13:25:33 UTC (rev 8640)
@@ -43,6 +43,7 @@
"24"
"25"
"26"
+"27"
"28"
"29"
"30"
Added: trunk/examples/python/x27
===================================================================
--- trunk/examples/python/x27 (rev 0)
+++ trunk/examples/python/x27 2008-08-13 13:25:33 UTC (rev 8640)
@@ -0,0 +1,39 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2008 Andrew Ross
+#
+# This file is part of PLplot.
+#
+# PLplot is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library General Public License as published
+# by the Free Software Foundation; version 2 of the License.
+#
+# PLplot is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with the file PLplot; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+
+# Run all python plplot examples non-interactively.
+
+# Append to effective python path so that can find plplot modules.
+from plplot_python_start import *
+
+import sys
+from plplot import *
+
+# Parse and process command line arguments
+plparseopts(sys.argv, PL_PARSE_FULL)
+
+# Initialize plplot
+plinit()
+
+import xw27
+
+# Terminate plplot
+plend()
+
Property changes on: trunk/examples/python/x27
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Added: trunk/examples/python/xw27.py
===================================================================
--- trunk/examples/python/xw27.py (rev 0)
+++ trunk/examples/python/xw27.py 2008-08-13 13:25:33 UTC (rev 8640)
@@ -0,0 +1,116 @@
+# $Id:$
+#
+# Copyright (C) 2007 Arjen Markus
+# Copyright (C) 2008 Andrew Ross
+
+# Drawing "spirograph" curves - epitrochoids, cycolids, roulettes
+
+# This file is part of PLplot.
+#
+# PLplot is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Library Public License as published
+# by the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# PLplot is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Library General Public License for more details.
+#
+# You should have received a copy of the GNU Library General Public License
+# along with PLplot; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+from plplot_py_demos import *
+
+# main
+#
+# Generates two kinds of plots:
+# - construction of a cycloid (animated)
+# - series of epitrochoids and hypotrochoids
+
+def main():
+
+ # R, r, p, N
+ params = [ [21.0, 7.0, 7.0, 3.0], # Deltoid
+ [21.0, 7.0, 10.0, 3.0],
+ [21.0, -7.0, 10.0, 3.0],
+ [20.0, 3.0, 7.0, 20.0],
+ [20.0, 3.0, 10.0, 20.0],
+ [20.0, -3.0, 10.0, 20.0],
+ [20.0, 13.0, 7.0, 20.0],
+ [20.0, 13.0, 20.0, 20.0],
+ [20.0,-13.0, 20.0, 20.0] ]
+
+ # Illustrate the construction of a cycloid
+
+ # TODO
+ #cycloid();
+
+ # Loop over the various curves
+ # First an overview, then all curves one by one
+ plssub(3, 3) ; # Three by three window
+
+ for i in range(9) :
+ pladv(0) ;
+ plvpor( 0.0, 1.0, 0.0, 1.0 ) ;
+ spiro( params[i] ) ;
+
+ pladv(0) ;
+ plssub(1, 1) ; # One window per curve
+
+ for i in range(9):
+ pladv(0) ;
+ plvpor( 0.0, 1.0, 0.0, 1.0 ) ;
+ spiro( params[i] ) ;
+
+
+def spiro(params):
+ # Fill the coordinates
+ NPNT = 20000
+
+ windings = int(params[3]);
+ steps = int(NPNT/windings) ;
+ dphi = 8.0*arccos(-1.0)/steps ;
+
+ xmin = 0.0 ; # This initialisation is safe!
+ xmax = 0.0 ;
+ ymin = 0.0 ;
+ ymax = 0.0 ;
+
+ xcoord = zeros(windings*steps+1);
+ ycoord = zeros(windings*steps+1);
+
+ for i in range(windings*steps+1) :
+ phi = i * dphi ;
+ phiw = (params[0]-params[1])/params[1]*phi ;
+ xcoord[i] = (params[0]-params[1])*cos(phi) + params[2]*cos(phiw) ;
+ ycoord[i] = (params[0]-params[1])*sin(phi) - params[2]*sin(phiw) ;
+
+ if ( xmin > xcoord[i] ) :
+ xmin = xcoord[i] ;
+ if ( xmax < xcoord[i] ) :
+ xmax = xcoord[i] ;
+ if ( ymin > ycoord[i] ) :
+ ymin = ycoord[i] ;
+ if ( ymax < ycoord[i] ) :
+ ymax = ycoord[i] ;
+
+ if ( xmax-xmin > ymax-ymin ) :
+ scale = xmax - xmin ;
+ else :
+ scale = ymax - ymin ;
+
+ xmin = - 0.65 * scale ;
+ xmax = 0.65 * scale ;
+ ymin = - 0.65 * scale ;
+ ymax = 0.65 * scale ;
+
+ plwind( xmin, xmax, ymin, ymax ) ;
+
+ plcol0(1);
+ plline( xcoord, ycoord ) ;
+
+
+main()
Property changes on: trunk/examples/python/xw27.py
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision
Added: svn:eol-style
+ native
Modified: trunk/plplot_test/test_python.sh.in
===================================================================
--- trunk/plplot_test/test_python.sh.in 2008-08-13 12:32:08 UTC (rev 8639)
+++ trunk/plplot_test/test_python.sh.in 2008-08-13 13:25:33 UTC (rev 8640)
@@ -31,7 +31,7 @@
# Skip 21 if using Numeric - it doesn't work
# For 24 you need special fonts installed to get good result.
for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 \
-20 22 23 24 25 26 28 29 30 @NUMPY_EXAMPLES@ ; do
+20 22 23 24 25 26 27 28 29 30 @NUMPY_EXAMPLES@ ; do
@PYTHON_EXECUTABLE@ $pythondir/x$index -dev $device -o ${OUTPUT_DIR}/x${index}p.$dsuffix $options 2> test.error
status_code=$?
cat test.error
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|