jsxgraph 1.14.0 → 1.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -3
- package/distrib/docs/3d_linspace3d.js.html +16 -10
- package/distrib/docs/3d_point3d.js.html +0 -5
- package/distrib/docs/3d_sphere3d.js.html +92 -69
- package/distrib/docs/3d_view3d.js.html +24 -16
- package/distrib/docs/Angle.html +7 -7
- package/distrib/docs/CircumcircleSector.html +2 -2
- package/distrib/docs/Conic.html +1 -1
- package/distrib/docs/Ellipse.html +23 -1
- package/distrib/docs/Hyperbola.html +24 -1
- package/distrib/docs/JXG.Board.infobox.html +1 -1
- package/distrib/docs/JXG.Board_.html +130 -130
- package/distrib/docs/JXG.CanvasRenderer.html +10 -10
- package/distrib/docs/JXG.Composition.html +3 -3
- package/distrib/docs/JXG.GeometryElement.html +26 -26
- package/distrib/docs/JXG.Math.Numerics.html +45 -47
- package/distrib/docs/JXG.Math.Statistics.html +14 -15
- package/distrib/docs/JXG.Math.Tiling.html +3 -7
- package/distrib/docs/JXG.Math.html +101 -83
- package/distrib/docs/JXG.Point3D.html +2 -2
- package/distrib/docs/JXG.SVGRenderer.html +12 -12
- package/distrib/docs/JXG.Sphere3D.html +1255 -2
- package/distrib/docs/JXG.View3D.html +29 -29
- package/distrib/docs/JXG.html +20 -20
- package/distrib/docs/MajorSector.html +1 -1
- package/distrib/docs/MinorSector.html +1 -1
- package/distrib/docs/NonReflexAngle.html +1 -1
- package/distrib/docs/Parabola.html +1 -1
- package/distrib/docs/Point3D.html +1 -1
- package/distrib/docs/ReflexAngle.html +1 -1
- package/distrib/docs/Sector.html +12 -12
- package/distrib/docs/Sphere3D.html +17 -1
- package/distrib/docs/View3D.html +1 -1
- package/distrib/docs/base_board.js.html +63 -13
- package/distrib/docs/base_composition.js.html +3 -3
- package/distrib/docs/base_constants.js.html +1 -1
- package/distrib/docs/base_element.js.html +2 -1
- package/distrib/docs/base_text.js.html +2 -2
- package/distrib/docs/element_conic.js.html +35 -1
- package/distrib/docs/element_sector.js.html +6 -3
- package/distrib/docs/index.html +1 -1
- package/distrib/docs/math_math.js.html +64 -35
- package/distrib/docs/math_numerics.js.html +13 -12
- package/distrib/docs/math_statistics.js.html +19 -19
- package/distrib/docs/math_tiling.js.html +6 -288
- package/distrib/docs/parser_jessiecode.js.html +1 -1
- package/distrib/docs/renderer_canvas.js.html +7 -6
- package/distrib/docs/renderer_svg.js.html +15 -7
- package/distrib/docs/scripts/jsxgraphcore.js +2 -2
- package/distrib/docs/styles/jsxgraph.css +1 -1
- package/distrib/docs/utils_type.js.html +11 -4
- package/distrib/geogebra.min.js +1 -1
- package/distrib/geonext.min.js +1 -1
- package/distrib/index.d.ts +11 -0
- package/distrib/intergeo.min.js +1 -1
- package/distrib/jsxgraph.css +1 -1
- package/distrib/jsxgraphcore.js +2 -2
- package/distrib/jsxgraphcore.mjs +2 -2
- package/distrib/jsxgraphcore.mjs.map +1 -1
- package/distrib/jsxgraphsrc.js +380 -496
- package/distrib/jsxgraphsrc.mjs +380 -496
- package/distrib/jsxgraphsrc.mjs.map +1 -1
- package/package.json +10 -12
- package/src/3d/linspace3d.js +16 -10
- package/src/3d/point3d.js +0 -5
- package/src/3d/sphere3d.js +92 -69
- package/src/3d/view3d.js +24 -16
- package/src/base/board.js +63 -13
- package/src/base/composition.js +3 -3
- package/src/base/constants.js +1 -1
- package/src/base/element.js +2 -1
- package/src/base/text.js +2 -2
- package/src/element/conic.js +35 -1
- package/src/element/sector.js +6 -3
- package/src/index.d.ts +11 -0
- package/src/math/math.js +64 -35
- package/src/math/numerics.js +13 -12
- package/src/math/statistics.js +19 -19
- package/src/math/tiling.js +6 -288
- package/src/parser/jessiecode.js +1 -1
- package/src/renderer/canvas.js +7 -6
- package/src/renderer/svg.js +15 -7
- package/src/utils/type.js +11 -4
- package/src/unused/bst.js +0 -475
- package/src/unused/heap.js +0 -135
- package/src/unused/locus.js +0 -162
- package/src/unused/server/JXG.py +0 -74
- package/src/unused/server/JXGServer.py +0 -94
- package/src/unused/server/JXGServerModule.py +0 -9
- package/src/unused/server/README.md +0 -63
- package/src/unused/server/RStats.py +0 -45
- package/src/unused/server/YahooFinance.py +0 -81
- package/src/unused/server/fft.py +0 -136
- package/src/unused/server/geoloci.py +0 -210
- package/src/unused/server/jxggroebner.py +0 -219
- package/src/unused/server/jxgtestplugin.py +0 -19
- package/src/unused/server/server.js +0 -280
- package/src/unused/sketch.js +0 -2895
- package/src/unused/symbolic.js +0 -416
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
from JXGServerModule import JXGServerModule
|
|
2
|
-
import JXG
|
|
3
|
-
|
|
4
|
-
import numpy
|
|
5
|
-
import os
|
|
6
|
-
|
|
7
|
-
# Should be changed to something more persistent but must be writable by
|
|
8
|
-
# the webserver (usually user www-data)
|
|
9
|
-
if not 'MPLCONFIGDIR' in os.environ:
|
|
10
|
-
os.environ['MPLCONFIGDIR'] = '/tmp/'
|
|
11
|
-
# os.environ['MPLCONFIGDIR'] = 'C:/xampp/tmp'
|
|
12
|
-
|
|
13
|
-
import matplotlib
|
|
14
|
-
matplotlib.use('Agg')
|
|
15
|
-
from matplotlib.pyplot import *
|
|
16
|
-
from matplotlib.contour import *
|
|
17
|
-
|
|
18
|
-
import subprocess
|
|
19
|
-
import signal
|
|
20
|
-
import time
|
|
21
|
-
import re
|
|
22
|
-
import zlib
|
|
23
|
-
import base64
|
|
24
|
-
import io
|
|
25
|
-
import cgi
|
|
26
|
-
import math
|
|
27
|
-
|
|
28
|
-
class JXGGeoLociModule(JXGServerModule):
|
|
29
|
-
|
|
30
|
-
def __init__(self):
|
|
31
|
-
|
|
32
|
-
############################
|
|
33
|
-
#
|
|
34
|
-
# Config lines
|
|
35
|
-
#
|
|
36
|
-
############################
|
|
37
|
-
|
|
38
|
-
# Command to start cocoa
|
|
39
|
-
self.cmd_cocoa = "/share8/opt/cocoa/cocoa"
|
|
40
|
-
# If you're using Windows
|
|
41
|
-
#cmd_cocoa = r"C:\cocoa\cocoa.bat"
|
|
42
|
-
|
|
43
|
-
# Shouldn't be changed, except you know what you're doing
|
|
44
|
-
self.debug = False
|
|
45
|
-
|
|
46
|
-
############################
|
|
47
|
-
|
|
48
|
-
self.debugOutput = io.StringIO()
|
|
49
|
-
|
|
50
|
-
JXGServerModule.__init__(self)
|
|
51
|
-
return
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
def init(self, resp):
|
|
55
|
-
resp.addHandler(self.lociCoCoA, 'function(data) { }')
|
|
56
|
-
return
|
|
57
|
-
|
|
58
|
-
def lociCoCoA(self, resp, xs, xe, ys, ye, number, polys, sf, rot, transx, transy):
|
|
59
|
-
self.output = ''
|
|
60
|
-
self.cococa_process = None
|
|
61
|
-
cinput = ""
|
|
62
|
-
c = math.cos(rot)
|
|
63
|
-
s = math.sin(rot)
|
|
64
|
-
tx = 0;
|
|
65
|
-
|
|
66
|
-
# Variable code begins here
|
|
67
|
-
# Here indeterminates of polynomial ring have to be adjusted
|
|
68
|
-
|
|
69
|
-
if number > 0:
|
|
70
|
-
cinput += "Use R ::= QQ[u[1..%s],x,y], Xel;" % number
|
|
71
|
-
else:
|
|
72
|
-
cinput += "Use R ::= QQ[x,y];"
|
|
73
|
-
|
|
74
|
-
# Of course the polynomials generating the ideal must be adjusted
|
|
75
|
-
cinput += "I := Ideal(%s);" % polys
|
|
76
|
-
|
|
77
|
-
# So have to be the indeterminates to be eliminated
|
|
78
|
-
if number > 0:
|
|
79
|
-
cinput += "J := Elim(u[1]..u[%s], I); J;" % number
|
|
80
|
-
else:
|
|
81
|
-
cinput += "J := I; J;"
|
|
82
|
-
|
|
83
|
-
# and ends here
|
|
84
|
-
|
|
85
|
-
# Fixed code which hasn't to be adjusted on each run of this script
|
|
86
|
-
cinput += "G := ReducedGBasis(J);"
|
|
87
|
-
cinput += "Print \"resultsbegin\", NewLine;"
|
|
88
|
-
cinput += "For N := 1 To Len(G) Do\n"
|
|
89
|
-
cinput += " B := Factor(G[N]);\n"
|
|
90
|
-
cinput += " For M := 1 To Len(B) Do\n"
|
|
91
|
-
cinput += " StarPrintFold(B[M][1], -1);"
|
|
92
|
-
cinput += " Print NewLine;"
|
|
93
|
-
cinput += " EndFor;\n"
|
|
94
|
-
cinput += "EndFor;\n"
|
|
95
|
-
cinput += "Print \"resultsend\", NewLine;"
|
|
96
|
-
#cinput = "Ciao;"
|
|
97
|
-
|
|
98
|
-
if self.debug:
|
|
99
|
-
print("Starting CoCoA with input<br />", file=self.debugOutput)
|
|
100
|
-
print(cinput + '<br />', file=self.debugOutput)
|
|
101
|
-
|
|
102
|
-
# The suicide pill for the CoCoA process:
|
|
103
|
-
# If not done within the following amount
|
|
104
|
-
# of seconds, the subprocess will be terminated
|
|
105
|
-
|
|
106
|
-
time_left = 30
|
|
107
|
-
|
|
108
|
-
class TimeoutException(Exception): pass
|
|
109
|
-
|
|
110
|
-
def time_limit(seconds):
|
|
111
|
-
def signal_handler(signum, frame):
|
|
112
|
-
raise TimeoutException("Timed out!")
|
|
113
|
-
signal.signal(signal.SIGALRM, signal_handler)
|
|
114
|
-
signal.alarm(seconds)
|
|
115
|
-
|
|
116
|
-
#global cocoa_process
|
|
117
|
-
#global output
|
|
118
|
-
|
|
119
|
-
def callCoCoA():
|
|
120
|
-
# Global variables aren't that nice, but this time they're useful
|
|
121
|
-
#global cocoa_process, output
|
|
122
|
-
self.cocoa_process = subprocess.Popen([self.cmd_cocoa], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
|
|
123
|
-
self.output = self.cocoa_process.communicate(cinput)[0]
|
|
124
|
-
|
|
125
|
-
calc_time = time.time()
|
|
126
|
-
try:
|
|
127
|
-
time_limit(time_left)
|
|
128
|
-
callCoCoA()
|
|
129
|
-
except TimeoutException as msg:
|
|
130
|
-
# This is only tested with linux/unix
|
|
131
|
-
# and works ONLY if the cocoa script cd-ing
|
|
132
|
-
# to the cocoa dir and starting cocoa executes
|
|
133
|
-
# it with
|
|
134
|
-
# $ exec ./cocoa_text
|
|
135
|
-
# This is NOT YET TESTED WITH WINDOWS! (though
|
|
136
|
-
# sharing tests would be nice).
|
|
137
|
-
self.cocoa_process.kill()
|
|
138
|
-
if self.debug:
|
|
139
|
-
print("Timed out!", file=self.debugOutput)
|
|
140
|
-
resp.error("Timeout, maybe the system of polynomial is too big or there's an error in it.")
|
|
141
|
-
return
|
|
142
|
-
|
|
143
|
-
calc_time = time.time() - calc_time
|
|
144
|
-
resp.addData('exectime', calc_time)
|
|
145
|
-
|
|
146
|
-
if self.debug:
|
|
147
|
-
print("Reading and Parsing CoCoA output" + '<br />', file=self.debugOutput)
|
|
148
|
-
print(self.output + '<br />', file=self.debugOutput)
|
|
149
|
-
|
|
150
|
-
# Extract results
|
|
151
|
-
if re.search('resultsbegin', self.output) is None:
|
|
152
|
-
return
|
|
153
|
-
result = re.split('resultsend', re.split('resultsbegin', self.output)[1])[0]
|
|
154
|
-
result = re.split('-------------------------------', re.split('-------------------------------', result)[1])[0]
|
|
155
|
-
result = result.replace("^", "**")
|
|
156
|
-
result = result.replace("\r", "")
|
|
157
|
-
polynomials = re.split('\n', result)
|
|
158
|
-
|
|
159
|
-
if self.debug:
|
|
160
|
-
print("Found the following polynomials:" + '<br />', file=self.debugOutput)
|
|
161
|
-
for i in range(0,len(polynomials)):
|
|
162
|
-
print("Polynomial ", i+1, ": " + polynomials[i] + '<br />', file=self.debugOutput)
|
|
163
|
-
|
|
164
|
-
datax = []
|
|
165
|
-
datay = []
|
|
166
|
-
polynomialsReturn = []
|
|
167
|
-
|
|
168
|
-
for i in range(0,len(polynomials)):
|
|
169
|
-
if len(polynomials[i]) == 0:
|
|
170
|
-
continue
|
|
171
|
-
if ((not "x" in polynomials[i]) and (not "y" in polynomials[i])) or ("W" in polynomials[i]):
|
|
172
|
-
continue
|
|
173
|
-
|
|
174
|
-
polynomialsReturn.append(polynomials[i])
|
|
175
|
-
x, y = numpy.meshgrid(numpy.linspace(xs, xe, 500), numpy.linspace(ys, ye, 500))
|
|
176
|
-
|
|
177
|
-
z = eval(polynomials[i])
|
|
178
|
-
C = contour(x, y, z, [0])
|
|
179
|
-
|
|
180
|
-
if self.debug:
|
|
181
|
-
savefig('/tmp/test%s.png' % i)
|
|
182
|
-
|
|
183
|
-
for i in range(0, len(C.collections[0].get_paths())):
|
|
184
|
-
pa = C.collections[0].get_paths()[i].to_polygons()[0]
|
|
185
|
-
|
|
186
|
-
for i in range(0,len(pa)):
|
|
187
|
-
tx = pa[i, 0]
|
|
188
|
-
pa[i, 0] = c*pa[i,0] - s*pa[i,1]
|
|
189
|
-
pa[i, 1] = s*tx + c*pa[i,1]
|
|
190
|
-
datax.append(sf*pa[i,0] + transx)
|
|
191
|
-
datay.append(sf*pa[i,1] + transy)
|
|
192
|
-
|
|
193
|
-
datax.append('null')
|
|
194
|
-
datay.append('null')
|
|
195
|
-
|
|
196
|
-
resp.addData('datax', datax)
|
|
197
|
-
resp.addData('datay', datay)
|
|
198
|
-
resp.addData('polynomial', polynomialsReturn)
|
|
199
|
-
|
|
200
|
-
if self.debug:
|
|
201
|
-
print(", ".join(map(str, datax)) + '<br />', file=self.debugOutput)
|
|
202
|
-
print(", ".join(map(str, datay)) + '<br />', file=self.debugOutput)
|
|
203
|
-
print("Content-Type: text/plain\n\n")
|
|
204
|
-
print()
|
|
205
|
-
print()
|
|
206
|
-
print(self.debugOutput.getvalue())
|
|
207
|
-
|
|
208
|
-
self.debugOutput.close()
|
|
209
|
-
|
|
210
|
-
return
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
|
|
3
|
-
import numpy
|
|
4
|
-
import os
|
|
5
|
-
|
|
6
|
-
############################
|
|
7
|
-
#
|
|
8
|
-
# Config lines
|
|
9
|
-
#
|
|
10
|
-
############################
|
|
11
|
-
|
|
12
|
-
# Should be changed to something more persistent but must be writable by
|
|
13
|
-
# the webserver
|
|
14
|
-
if not 'MPLCONFIGDIR' in os.environ:
|
|
15
|
-
os.environ['MPLCONFIGDIR'] = '/tmp'
|
|
16
|
-
# Example for Windows using XAMPP
|
|
17
|
-
# os.environ['MPLCONFIGDIR'] = 'C:/xampp/tmp'
|
|
18
|
-
|
|
19
|
-
# Command to start cocoa
|
|
20
|
-
cmd_cocoa = "cocoa"
|
|
21
|
-
# If you're using Windows
|
|
22
|
-
#cmd_cocoa = r"C:\cocoa\cocoa.bat"
|
|
23
|
-
|
|
24
|
-
# Shouldn't be changed, except you know what you're doing
|
|
25
|
-
debug = False
|
|
26
|
-
|
|
27
|
-
############################
|
|
28
|
-
|
|
29
|
-
import matplotlib
|
|
30
|
-
matplotlib.use('Agg')
|
|
31
|
-
from matplotlib.pyplot import *
|
|
32
|
-
from matplotlib.contour import *
|
|
33
|
-
|
|
34
|
-
import subprocess
|
|
35
|
-
import signal
|
|
36
|
-
import re
|
|
37
|
-
import zlib
|
|
38
|
-
import base64
|
|
39
|
-
import io
|
|
40
|
-
import cgi
|
|
41
|
-
|
|
42
|
-
debugOutput = io.StringIO()
|
|
43
|
-
|
|
44
|
-
print("Content-Type: text/plain\n\n")
|
|
45
|
-
print()
|
|
46
|
-
print()
|
|
47
|
-
|
|
48
|
-
# Data required by this script:
|
|
49
|
-
#
|
|
50
|
-
# * Number of independent and dependent variables. Number of trace variables is always 2
|
|
51
|
-
# * Polynomials generating the ideal
|
|
52
|
-
# * Values of the independent variables
|
|
53
|
-
# * part of board displayed on screen
|
|
54
|
-
|
|
55
|
-
# Get Data from post/get parameters
|
|
56
|
-
form = cgi.FieldStorage();
|
|
57
|
-
|
|
58
|
-
number = form.getfirst('number', 'empty')
|
|
59
|
-
polys = form.getfirst('polynomials', 'empty')
|
|
60
|
-
|
|
61
|
-
# Get viewing rectangle of the board
|
|
62
|
-
xs = float(form.getfirst('xs', '-5'))
|
|
63
|
-
xe = float(form.getfirst('xe', '5'))
|
|
64
|
-
ys = float(form.getfirst('ys', '-5'))
|
|
65
|
-
ye = float(form.getfirst('ye', '5'))
|
|
66
|
-
|
|
67
|
-
# Clean them up
|
|
68
|
-
number = int(cgi.escape(number))
|
|
69
|
-
polys = base64.b64decode(cgi.escape(polys))
|
|
70
|
-
|
|
71
|
-
cinput = ""
|
|
72
|
-
|
|
73
|
-
# Variable code begins here
|
|
74
|
-
# Here indeterminates of polynomial ring have to be adjusted
|
|
75
|
-
|
|
76
|
-
if number > 0:
|
|
77
|
-
cinput += "Use R ::= QQ[u[1..%s],x,y];" % number
|
|
78
|
-
else:
|
|
79
|
-
cinput += "Use R ::= QQ[x,y];"
|
|
80
|
-
|
|
81
|
-
# Of course the polynomials generating the ideal must be adjusted
|
|
82
|
-
cinput += "I := Ideal(%s);" % polys
|
|
83
|
-
|
|
84
|
-
# So have to be the indeterminates to be eliminated
|
|
85
|
-
if number > 0:
|
|
86
|
-
cinput += "J := Elim(u[1]..u[%s], I); J;" % number
|
|
87
|
-
else:
|
|
88
|
-
cinput += "J := I; J;"
|
|
89
|
-
|
|
90
|
-
# and ends here
|
|
91
|
-
|
|
92
|
-
# Fixed code which hasn't to be adjusted on each run of this script
|
|
93
|
-
cinput += "G := ReducedGBasis(J);"
|
|
94
|
-
cinput += "Print \"resultsbegin\", NewLine;"
|
|
95
|
-
cinput += "For N := 1 To Len(G) Do\n"
|
|
96
|
-
cinput += " B := Factor(G[N]);\n"
|
|
97
|
-
cinput += " For M := 1 To Len(B) Do\n"
|
|
98
|
-
cinput += " StarPrintFold(B[M][1], -1);"
|
|
99
|
-
cinput += " Print NewLine;"
|
|
100
|
-
cinput += " EndFor;\n"
|
|
101
|
-
cinput += "EndFor;\n"
|
|
102
|
-
cinput += "Print \"resultsend\", NewLine;"
|
|
103
|
-
|
|
104
|
-
if debug:
|
|
105
|
-
print("Starting CoCoA with input<br />", file=debugOutput)
|
|
106
|
-
print(cinput + '<br />', file=debugOutput)
|
|
107
|
-
|
|
108
|
-
#cocoa = subprocess.Popen([cmd_cocoa], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
|
|
109
|
-
|
|
110
|
-
# The suicide pill for the CoCoA process:
|
|
111
|
-
# If not done within the following amount
|
|
112
|
-
# of seconds, the subprocess will be terminated
|
|
113
|
-
|
|
114
|
-
time_left = 20
|
|
115
|
-
|
|
116
|
-
class TimeoutException(Exception): pass
|
|
117
|
-
|
|
118
|
-
def time_limit(seconds):
|
|
119
|
-
def signal_handler(signum, frame):
|
|
120
|
-
raise TimeoutException("Timed out!")
|
|
121
|
-
signal.signal(signal.SIGALRM, signal_handler)
|
|
122
|
-
signal.alarm(seconds)
|
|
123
|
-
|
|
124
|
-
cocoa_process = None
|
|
125
|
-
output = ''
|
|
126
|
-
|
|
127
|
-
def callCoCoA():
|
|
128
|
-
# Global variables aren't that nice, but this time is see no way out
|
|
129
|
-
global cocoa_process, output
|
|
130
|
-
cocoa_process = subprocess.Popen([cmd_cocoa], stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=False)
|
|
131
|
-
#cocoa_process.stdin.write(input)
|
|
132
|
-
output = cocoa_process.communicate(cinput)[0]
|
|
133
|
-
#cocoa_process.stdin.close()
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
try:
|
|
137
|
-
time_limit(time_left)
|
|
138
|
-
callCoCoA()
|
|
139
|
-
except TimeoutException as msg:
|
|
140
|
-
# This is only tested with linux/unix
|
|
141
|
-
# and works ONLY if the cocoa script cd-ing
|
|
142
|
-
# to the cocoa dir and starting cocoa executes
|
|
143
|
-
# it with
|
|
144
|
-
# $ exec ./cocoa_text
|
|
145
|
-
# This is NOT YET TESTED WITH WINDOWS! (though
|
|
146
|
-
# sharing tests would be nice).
|
|
147
|
-
cocoa_process.kill()
|
|
148
|
-
#cocoa_process.terminate()
|
|
149
|
-
#cocoa_process.send_signal(signal.SIGTERM)
|
|
150
|
-
#subprocess.Popen(["killall", "cocoa_text"])
|
|
151
|
-
#os.system('killall -9 cocoa_text')
|
|
152
|
-
if debug:
|
|
153
|
-
print("Timed out!", file=debugOutput)
|
|
154
|
-
exit()
|
|
155
|
-
|
|
156
|
-
#cocoa = os.popen("echo \"" + input + "\" | " + cmd_cocoa)
|
|
157
|
-
|
|
158
|
-
#output = cocoa.read()
|
|
159
|
-
|
|
160
|
-
if debug:
|
|
161
|
-
print("Reading and Parsing CoCoA output" + '<br />', file=debugOutput)
|
|
162
|
-
print(output + '<br />', file=debugOutput)
|
|
163
|
-
|
|
164
|
-
# Extract results
|
|
165
|
-
result = re.split('resultsend', re.split('resultsbegin', output)[1])[0]
|
|
166
|
-
result = re.split('-------------------------------', re.split('-------------------------------', result)[1])[0]
|
|
167
|
-
result = result.replace("^", "**")
|
|
168
|
-
result = result.replace("\r", "")
|
|
169
|
-
polynomials = re.split('\n', result)
|
|
170
|
-
|
|
171
|
-
if debug:
|
|
172
|
-
print("Found the following polynomials:" + '<br />', file=debugOutput)
|
|
173
|
-
for i in range(0,len(polynomials)):
|
|
174
|
-
print("Polynomial ", i+1, ": " + polynomials[i] + '<br />', file=debugOutput)
|
|
175
|
-
|
|
176
|
-
data = io.StringIO()
|
|
177
|
-
polynomialsReturn = ""
|
|
178
|
-
|
|
179
|
-
for i in range(0,len(polynomials)):
|
|
180
|
-
if len(polynomials[i]) == 0:
|
|
181
|
-
continue
|
|
182
|
-
if ((not "x" in polynomials[i]) and (not "y" in polynomials[i])) or ("W" in polynomials[i]):
|
|
183
|
-
continue
|
|
184
|
-
|
|
185
|
-
polynomialsReturn = polynomialsReturn + polynomials[i] + ";"
|
|
186
|
-
x, y = numpy.meshgrid(numpy.linspace(xs, xe, 200), numpy.linspace(ys, ye, 200))
|
|
187
|
-
|
|
188
|
-
z = eval(polynomials[i])
|
|
189
|
-
C = contour(x, y, z, [0])
|
|
190
|
-
|
|
191
|
-
if debug:
|
|
192
|
-
savefig('/tmp/test%s.png' % i)
|
|
193
|
-
|
|
194
|
-
for i in range(0, len(C.collections[0].get_paths())):
|
|
195
|
-
pa = C.collections[0].get_paths()[i].to_polygons()[0]
|
|
196
|
-
|
|
197
|
-
for i in range(0,len(pa)):
|
|
198
|
-
print(pa[i,0], ",", pa[i,1], ";", file=data)
|
|
199
|
-
|
|
200
|
-
print(";", file=data)
|
|
201
|
-
|
|
202
|
-
print("-----", file=data)
|
|
203
|
-
print(polynomialsReturn,";", file=data)
|
|
204
|
-
|
|
205
|
-
enc_data = base64.b64encode(zlib.compress(data.getvalue(), 9))
|
|
206
|
-
|
|
207
|
-
if debug:
|
|
208
|
-
fd = open('/tmp/tmp.txt', 'w')
|
|
209
|
-
fd.write(data.getvalue())
|
|
210
|
-
fd.close()
|
|
211
|
-
|
|
212
|
-
if debug:
|
|
213
|
-
print(data.getvalue() + '<br />', file=debugOutput)
|
|
214
|
-
print(debugOutput.getvalue())
|
|
215
|
-
|
|
216
|
-
print(enc_data)
|
|
217
|
-
|
|
218
|
-
data.close()
|
|
219
|
-
debugOutput.close()
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
from JXGServerModule import JXGServerModule
|
|
2
|
-
import JXG
|
|
3
|
-
|
|
4
|
-
class JXGTestModule(JXGServerModule):
|
|
5
|
-
|
|
6
|
-
def init(self, resp):
|
|
7
|
-
s = '''
|
|
8
|
-
function (x) {
|
|
9
|
-
alert(x);
|
|
10
|
-
};
|
|
11
|
-
'''
|
|
12
|
-
resp.addField('JXG.Math.Numerics', 'test', s)
|
|
13
|
-
|
|
14
|
-
resp.addHandler(self.calcTest, 'function(data) { alert(data.y); }')
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
def calcTest(self, resp, x):
|
|
18
|
-
resp.addData('y', 3*x)
|
|
19
|
-
return
|