Fixed bug in my CC implementation

- Wasn't calculating faces for a give original vert correctly
    - vertices generated by surf.subd.cc.refine look about right
    - still missing edge and face connectivity
This commit is contained in:
Stephen M. McQuay
2012-05-09 09:24:26 -06:00
parent ba1ec89c27
commit 198a7d7ca8
3 changed files with 33 additions and 14 deletions
+12
View File
@@ -25,6 +25,7 @@ def cross(a, b):
k = a.x * b.y - a.y * b.x
return Vertex(i, j, k)
def centroid(verts):
xs = [v.x for v in verts]
ys = [v.y for v in verts]
@@ -37,6 +38,7 @@ def centroid(verts):
return Vertex(x, y, z)
class Vertex(object):
'''
A vertex is a position along with other information such as color, normal
@@ -72,6 +74,16 @@ class Vertex(object):
raise TypeError("{0} has an unexpected type: {1}".format(
other, type(other)))
def __iter__(self):
"""Added to be able to conveniently convert a Vertex into a list
>>> v = Vertex(0, 1, 2)
>>> assert list(v) == [0, 1, 2]
"""
yield self.x
yield self.y
yield self.z
def __rmul__(self, other):
return self.__mul__(other)