0

More than 1 year has passed since last update.

「関数グラフソフトGRAPES」のGPSフォーマットをsympyでprint出力しました。(正五角形を作図)

Last updated at Posted at 2022-08-19

ソースは、約300行長文です。

スクリプトも操作も、勉強中です。

GRAPESで「画像の保存」です。

sympyで

``````from sympy import *
def myTextRepInit(myText):
GPS_List = myText.splitlines()
del GPS_List[0]
joined = '\n'.join(GPS_List)
return joined
def myTextRep(myText,n,myT):
GPS_List = myText.splitlines()
GPS_List[n-1]=myT
joined = '\n'.join(GPS_List)
return joined
GPS_Text="""
Grapes/win 2.9
[Don't Edit] 3.14
----------
BGstretchOn BGfile
1
----------
UserFunction
0
----------
y = f(x)
0
----------
0 = f(x,y)
0
----------
Point
22 0 0 0 0 0 0 0 1 2 3 4 5 6 0 0 0 0 0 0 0 0 22 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0
P
0 3 2
Q
0 3 2
R
0 3 2
S
0 3 2
T
0 3 2
U
0 3 2
V
0 3 2
A
1 3 2
A
-2.10
-2.49
0

t 0.1
0 0
16711680 16711680 16777215 1 0 1 3 1 0 0
4 0 3 0 0
B
1 3 2
B
1.92
-2.45
0

t 0.1
0 0
16711680 16711680 16777215 1 0 1 3 1 0 0
4 0 3 0 0
C
1 3 2
C
3.35
0.41
0

t 0.1
0 0
16711680 16711680 16777215 1 0 1 3 1 0 0
4 0 3 0 0
D
1 3 2
D
-2.69
1.21
0

t 0.1
0 0
16711680 16711680 16777215 1 0 1 3 1 0 0
4 0 3 0 0
E
1 3 2
E
-3.52
-0.80
0

t 0.1
0 0
16711680 16711680 16777215 1 0 1 3 1 0 0
4 0 3 0 0
F
1 3 2

-2.10
-2.49
0

t 0.1
0 0
16711680 16711680 16777215 1 0 1 3 1 0 0
4 0 3 0 0
G
0 3 2
H
0 3 2
I
0 3 2
J
0 3 2
K
0 3 2
L
0 3 2
M
0 3 2
N
0 3 2
O
1 0 2
O
0
0

t 0.1
0 0
16777215 16711680 16777215 1 0 0 3 1 0 0
4 0 2 0 0
----------
Segments
1
6 1 1 16711680 16777215 2 0 1 1 0 1
0
8 9 10 11 12 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
----------
paramater
14
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
0 0
1 1 0.1 1 0 0
1 0
1 1 0.1 1 0 0
1 1 98
----------
KakuMode ScanWidth LogMode ThetaMode AreaMode capStyle
1 4 2 2 1 0 1 1 0 1 0 40 0 0
DrawMode SegmentShowSync
1 0
AfterImageColorNo, CanAImg,MaxAimgN0
2 1 3001
circleMode
1
----------
ScaleX
Vlow,VHigh,label
0 910 x
x
1 1 1 0 1 0
NUmber,Base,Linterval,numberR
8 1 1 8
High,Low
5 -5
----------
ScaleY
Vlow,VHigh,label
0 910 y
1 1 1 1 0 0
NUmber,Base,Linterval,NumbeerR
8 1 1 8
High,Low
5 -5
----------
ScaleS
SquareQ AreaRectify PsMesh AxisWidth FontSize AxisOn letterCenterShowPOsition ShowEquation AxisType PolorNum Areafixed
0 1 0 1 14 0 0 0 0 0 8 0 0 0 24
----------
Yvalue
1 1
----------
Iinterval
Svalue Evalue sliceNo
1 -1
1 1
40 10
Dfuncno Efuncno AreaQ
1 0 0
----------
Yvalue Function List
0
----------
Panel Position
0 32 64 96 326 358 390 422 1 1 1 1 1 1 1 1
1
----------
PetaMEMO SECTION
Style, Color, BGcolor , height, PositionX, positionY
3 16711680 0 14 24 0 0

0

----------
21
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
0 -38 0
----------
Table SECTION
RowNo, ColumnNo
0 10 201
Table Data

60 60 60 60 60 60 60 60 60 60
----------
SimpleMemo SECTION
0
----------
"""
t=(2*pi)/5
A=Point(cos(pi/2+t*2),sin(pi/2+t*2))
B=Point(cos(pi/2+t*3),sin(pi/2+t*3))
C=Point(cos(pi/2+t*4),sin(pi/2+t*4))
D=Point(cos(pi/2+t*0),sin(pi/2+t*0))
E=Point(cos(pi/2+t*1),sin(pi/2+t*1))
GPS_Text=myTextRepInit(GPS_Text)
GPS_Text=myTextRep(GPS_Text,35,str(A.x))
GPS_Text=myTextRep(GPS_Text,36,str(A.y))
GPS_Text=myTextRep(GPS_Text,47,str(B.x))
GPS_Text=myTextRep(GPS_Text,48,str(B.y))
GPS_Text=myTextRep(GPS_Text,59,str(C.x))
GPS_Text=myTextRep(GPS_Text,60,str(C.y))
GPS_Text=myTextRep(GPS_Text,71,str(D.x))
GPS_Text=myTextRep(GPS_Text,72,str(D.y))
GPS_Text=myTextRep(GPS_Text,83,str(E.x))
GPS_Text=myTextRep(GPS_Text,84,str(E.y))
GPS_Text=myTextRep(GPS_Text,95,str(A.x))
GPS_Text=myTextRep(GPS_Text,96,str(A.y))
print(GPS_Text)
``````

print文の出力抜粋(34～36行目)

``````A
-sqrt(5/8 - sqrt(5)/8)
-sqrt(5)/4 - 1/4
``````

参考

この記事は以下の記事からリンクされています

Register as a new user and use Qiita more conveniently

1. You get articles that match your needs
2. You can efficiently read back useful information
3. You can use dark theme
What you can do with signing up
0