Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions py-scripts/export-ggb-clean-asy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import argparse
import io
import math
import re
import string
import sys
Expand Down Expand Up @@ -126,17 +127,15 @@ def replace_numbers(s):
coords = eval(point_coords)

if coords is None:
figures_output_code += (
r'dot("%s", %s, dir(45));' % (label, point_coords) + "\n"
)
figures_output_code += f'dot("{label}", {point_coords}, dir(45));\n'
else:
# determine the direction
dx = 100 * (label_loc[0] - coords[0])
dy = 100 * (label_loc[1] - coords[1])
figures_output_code += (
r'dot("%s", %s, dir((%.3f, %.3f)));' % (label, point_coords, dx, dy)
+ "\n"
)
vdir = round(math.degrees(math.atan2(dy, dx)))
if vdir < 0:
vdir += 360
figures_output_code += f'dot("{label}", {point_coords}, dir({vdir}));\n'
label_to_coords[label] = point_coords

# now clean up the code if possible by replacing explicit coordinates where we can
Expand Down
Loading