Skip to content

Instantly share code, notes, and snippets.

Created March 7, 2014 17:13
Show Gist options
  • Save anonymous/9415592 to your computer and use it in GitHub Desktop.
Save anonymous/9415592 to your computer and use it in GitHub Desktop.
test
if isPointOnEdge(vX, vA, vB):
oe[edge_count].vertices = [vc, vc+1]
oe[edge_count+1].vertices = [vc, vc+2]
# find which of C and D is farthest away from X
if mDist(vD, vX) > mDist(vC, vX):
oe[edge_count+2].vertices = [vc, vc+3]
oe[edge_count+3].vertices = [vc+3, vc+4]
if mDist(vC, vX) > mDist(vD, vX):
oe[edge_count+2].vertices = [vc, vc+4]
oe[edge_count+3].vertices = [vc+3, vc+4]
if isPointOnEdge(vX, vC, vD):
oe[edge_count].vertices = [vc, vc+3]
oe[edge_count+1].vertices = [vc, vc+4]
# find which of A and B is farthest away from X
if mDist(vB, vX) > mDist(vA, vX):
oe[edge_count+2].vertices = [vc, vc+1]
oe[edge_count+3].vertices = [vc+1, vc+2]
if mDist(vA, vX) > mDist(vB, vX):
oe[edge_count+2].vertices = [vc, vc+2]
oe[edge_count+3].vertices = [vc+1, vc+2]
'''------------------- step 1 ----------------'''
def PointCreation(v1, v2, rs1=1, kv1=3):
rs2 = rs1 + 1
kv2 = kv1 + 1
oe[edge_count].vertices = [vc, vc + kv1]
oe[edge_count+1].vertices = [vc, vc + kv2]
# find which of v2 and v1 is farthest away from X
if mDist(v1, vX) > mDist(v2, vX):
oe[edge_count+2].vertices = [vc, vc + rs1]
oe[edge_count+3].vertices = [vc + rs1, vc + rs2]
if mDist(v2, vX) > mDist(v1, vX):
oe[edge_count+2].vertices = [vc, vc + rs2]
oe[edge_count+3].vertices = [vc + rs1, vc + rs2]
if isPointOnEdge(vX, vA, vB):
PointCreation(vB, vA, rs1=3, kv1=1)
elif isPointOnEdge(vX, vC, vD):
PointCreation(vD, vC)
'''------------------- step 2 ----------------'''
def amux(gv1, gv2, gv3):
oe[edge_count+2].vertices = [vc, vc + gv1
oe[edge_count+3].vertices = [vc + gv2, vc + gv3]
def PointCreation(v1, v2, rs1=1, kv1=3):
oe[edge_count].vertices = [vc, vc + kv1]
oe[edge_count+1].vertices = [vc, vc + kv1 + 1]
# find which of v2 and v1 is farthest away from X
if mDist(v1, vX) > mDist(v2, vX):
amux(rs1, rs1, rs1+1):
else:
amux(rs1+1, rs1, rs1+1):
if isPointOnEdge(vX, vA, vB):
PointCreation(vB, vA, rs1=3, kv1=1)
elif isPointOnEdge(vX, vC, vD):
PointCreation(vD, vC)
'''------------------- step 3 ----------------'''
# find which of v2 and v1 is farthest away from X
def further(v1, v2):
return mDist(v1, vX) > mDist(v2, vX)
def amux(gv1, gv2, gv3):
oe[edge_count+2].vertices = [vc, vc + gv1
oe[edge_count+3].vertices = [vc + gv2, vc + gv3]
def pCreate(v1, v2, r=1, k=3):
oe[edge_count].vertices = [vc, vc + k]
oe[edge_count+1].vertices = [vc, vc + k + 1]
new_geom = [r, r, r+1] if further(v1,v2) else [r+1, r, r+1]
amux(*new_geom)
if isPointOnEdge(vX, vA, vB):
pointCreate(vB, vA, r=3, k=1)
if isPointOnEdge(vX, vC, vD):
pointCreate(vD, vC)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment