normalize angles
This commit is contained in:
parent
f3cfc7f314
commit
7c1c2a609b
@ -3,6 +3,13 @@ from collections import namedtuple
|
|||||||
from decimal import Decimal as Dec
|
from decimal import Decimal as Dec
|
||||||
from math import sin, cos, pi
|
from math import sin, cos, pi
|
||||||
|
|
||||||
|
def normalize(ang):
|
||||||
|
while ang > 180:
|
||||||
|
ang -= 360
|
||||||
|
while ang <= -180:
|
||||||
|
ang += 360
|
||||||
|
return ang
|
||||||
|
|
||||||
def guess(inp):
|
def guess(inp):
|
||||||
if isinstance(inp, str) and '-' in inp:
|
if isinstance(inp, str) and '-' in inp:
|
||||||
deg, mm, ss = inp.split('-')
|
deg, mm, ss = inp.split('-')
|
||||||
@ -107,7 +114,7 @@ if __name__ == '__main__':
|
|||||||
nxt = vertices[1 if i == len(vertices) - 1 else i+1]
|
nxt = vertices[1 if i == len(vertices) - 1 else i+1]
|
||||||
|
|
||||||
pts = "%d-%d" % (v.point, nxt.point)
|
pts = "%d-%d" % (v.point, nxt.point)
|
||||||
draw = "@%.3f<%.4f" % (v.len, 90 - v.dirang)
|
draw = "@%.3f<%.4f" % (v.len, normalize(90 - v.dirang))
|
||||||
print("%5s: %19s acadcoords:(%.3f,%.3f)" % \
|
print("%5s: %19s acadcoords:(%.3f,%.3f)" % \
|
||||||
(pts, draw, v.coords.acadx, v.coords.acady))
|
(pts, draw, v.coords.acadx, v.coords.acady))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user