File: plot.py

package info (click to toggle)
jsxgraph 1.10.1%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 24,804 kB
  • sloc: javascript: 82,299; xml: 5,869; java: 1,072; php: 281; makefile: 184; python: 174; cpp: 76; sh: 12
file content (31 lines) | stat: -rw-r--r-- 629 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy
import math
import matplotlib
matplotlib.use('Agg')
from matplotlib.pyplot import *
from matplotlib.contour import *
#import js

xs = -5.0
xe = 5.0
ys = -5.0
ye = 5.0
x, y = numpy.meshgrid(numpy.linspace(xs, xe, 200), numpy.linspace(ys, ye, 200))

#r = math.sqrt(js.window.P.X() ** 2 + js.window.P.Y() ** 2)

r = math.sqrt(2**2+2**2)
z = eval(f"x**2 + y**2 - {r}")
C = contour(x, y, z, [0])

data = ""
for i in range(0, len(C.collections[0].get_paths())):
    pa = C.collections[0].get_paths()[i].to_polygons()[0]
    

    for j in range(0,len(pa)):
        data += f"{pa[j][0]},{pa[j][1]};"

    data += ";"

data