Progress with some manifold stuff
This commit is contained in:
parent
87ebd4efb4
commit
4115df52ed
23
cage.py
23
cage.py
@ -82,7 +82,7 @@ class Cage(object):
|
|||||||
and case 1 does not apply.
|
and case 1 does not apply.
|
||||||
3 -- cage.verts[i] equals a vertex in self.verts.
|
3 -- cage.verts[i] equals a vertex in self.verts.
|
||||||
"""
|
"""
|
||||||
v = numpy.array((cage.shape[0],) dtype=numpy.uint8)
|
v = numpy.zeros((cage.verts.shape[0],), dtype=numpy.uint8)
|
||||||
for i,vert in enumerate(cage.verts):
|
for i,vert in enumerate(cage.verts):
|
||||||
# Check against every vert in self.verts:
|
# Check against every vert in self.verts:
|
||||||
for j,vert2 in enumerate(self.verts):
|
for j,vert2 in enumerate(self.verts):
|
||||||
@ -91,13 +91,22 @@ class Cage(object):
|
|||||||
break
|
break
|
||||||
if v[i] > 0:
|
if v[i] > 0:
|
||||||
continue
|
continue
|
||||||
# Check against every edge in self.verts:
|
# Check against every edge of our own polygons:
|
||||||
for poly in self.polys():
|
for poly in self.polys():
|
||||||
# TODO:
|
for j,_ in enumerate(poly):
|
||||||
# Check if 'vert' lies within some threshold of each edge
|
j2 = (j + 1) % len(poly)
|
||||||
# in 'poly'.
|
# Find distance from 'vert' to each vertex of the edge:
|
||||||
# Note that 'poly' is cyclic - index (N-1) to 0 is an edge.
|
d1 = numpy.linalg.norm(poly[j,:] - vert)
|
||||||
raise Exception("Not implemented")
|
d2 = numpy.linalg.norm(poly[j2,:] - vert)
|
||||||
|
# Find the edge's length:
|
||||||
|
d = numpy.linalg.norm(poly[j2,:] - poly[j,:])
|
||||||
|
# These are equal if and only if the vertex lies along
|
||||||
|
# that edge:
|
||||||
|
if numpy.isclose(d, d1+d2):
|
||||||
|
v[i] = 1
|
||||||
|
break
|
||||||
|
if v[i] > 0:
|
||||||
|
break
|
||||||
if v[i] > 0:
|
if v[i] > 0:
|
||||||
continue
|
continue
|
||||||
# Check against every *other* vert in cage.verts:
|
# Check against every *other* vert in cage.verts:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user