degree calculator

This commit is contained in:
Motiejus Jakštys 2019-11-14 22:41:12 +02:00
parent bbd96ea985
commit 45fc776a1e
3 changed files with 32 additions and 12 deletions

1
.gitignore vendored
View File

@ -20,3 +20,4 @@ __pycache__
*.run.xml
env/
*.pyc

View File

@ -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.

View File

@ -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()