From 45fc776a1e5889ca2aa6a3709c6fe9bc69c9ad64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Thu, 14 Nov 2019 22:41:12 +0200 Subject: [PATCH] degree calculator --- .gitignore | 1 + Karto/README.md | 14 +++++++------- misc/tools.py | 29 ++++++++++++++++++++++++----- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 3a84a80..aeaca58 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ __pycache__ *.run.xml env/ +*.pyc diff --git a/Karto/README.md b/Karto/README.md index 9c3be06..f290fbd 100644 --- a/Karto/README.md +++ b/Karto/README.md @@ -15,10 +15,10 @@ useful commands: - f8: perpendicular - f2: console -questions: -- what to click to create an xline with the same offset (accept suggestion)? -- how to draw a semicircular? construction line: xl, bisect. -- how to add a dimension text (kelio ašis)? dt (dtext). -- how to make a legend? line type. -- how to add labels to the coordinate system? -- how to scale the overlay sheet of paper? stretch. +- rotate +- scale: by reference -- turint palyginimo objektą. + +- hutch: štrichavimas. +- draworder: bring to front/back. +- re: Regenerate screen +- circle: 2p/3p/ttr. Liestinės. diff --git a/misc/tools.py b/misc/tools.py index 1145e6a..4a82d81 100644 --- a/misc/tools.py +++ b/misc/tools.py @@ -1,7 +1,26 @@ - from decimal import Decimal -def deg(deg, mm, ss): - return (Decimal(deg) + - Decimal(mm) / Decimal(60) + - Decimal(ss) / Decimal(3600)).normalize() +class Deg: + def __str__(self): + return "%03d - %02d - %02d" % (self.deg, self.mm, self.ss) + + def __init__(self, deg, mm, ss): + self.deg = Decimal(deg) + self.mm = Decimal(mm) + self.ss = Decimal(ss) + + @staticmethod + def from_1(deg): + assert isinstance(deg, Decimal) + + pdeg, pmm = divmod(deg, 1) + pmm = pmm * Decimal(60) + pmm, pss = divmod(pmm, 1) + pss = pss * Decimal(60) + return Deg(pdeg, pmm, pss) + + def frac(self): + return ( + self.deg + + self.mm / Decimal(60) + + self.ss / Decimal(3600)).normalize()