Draft: move more functions to draftgeoutils.general

This commit is contained in:
vocx-fc
2020-06-02 09:28:21 -05:00
committed by Yorik van Havre
parent 0e82ae26cd
commit aba904f1e2
2 changed files with 47 additions and 40 deletions

View File

@@ -257,46 +257,7 @@ from draftgeoutils.faces import removeSplitter
# circle functions *********************************************************
def getBoundaryAngles(angle, alist):
"""returns the 2 closest angles from the list that
encompass the given angle"""
negs = True
while negs:
negs = False
for i in range(len(alist)):
if alist[i] < 0:
alist[i] = 2*math.pi + alist[i]
negs = True
if angle < 0:
angle = 2*math.pi + angle
negs = True
lower = None
for a in alist:
if a < angle:
if lower is None:
lower = a
else:
if a > lower:
lower = a
if lower is None:
lower = 0
for a in alist:
if a > lower:
lower = a
higher = None
for a in alist:
if a > angle:
if higher is None:
higher = a
else:
if a < higher:
higher = a
if higher is None:
higher = 2*math.pi
for a in alist:
if a < higher:
higher = a
return (lower,higher)
from draftgeoutils.general import getBoundaryAngles
# These functions are not imported because they are incomplete;

View File

@@ -293,3 +293,49 @@ def findClosest(base_point, point_list):
npoint = n
return npoint
def getBoundaryAngles(angle, alist):
"""Return the 2 closest angles that encompass the given angle."""
negs = True
while negs:
negs = False
for i in range(len(alist)):
if alist[i] < 0:
alist[i] = 2*math.pi + alist[i]
negs = True
if angle < 0:
angle = 2*math.pi + angle
negs = True
lower = None
for a in alist:
if a < angle:
if lower is None:
lower = a
else:
if a > lower:
lower = a
if lower is None:
lower = 0
for a in alist:
if a > lower:
lower = a
higher = None
for a in alist:
if a > angle:
if higher is None:
higher = a
else:
if a < higher:
higher = a
if higher is None:
higher = 2*math.pi
for a in alist:
if a < higher:
higher = a
return lower, higher