def face_point(self): total = Vec3d.zero() size = 0 for vertex in self.vertices: total += vertex.position size += 1 return total / size
def normal(self): normal = Vec3d.zero() e = start = self.edge while True: normal += e.face.normal e = e.prev.sys if e is start: break return normal.normalized
def normal(self): normal = Vec3d.zero() e = start = self.edge while True: v = e.vertex.position vnext = e.next.vertex.position normal += vnext.cross(v) if e is start: break return normal.normalized
def get_avg_face_points(mesh: WingedMesh): avg_face_points = [] total = Vec3d.zero() count = 0 for vertex in mesh.vertices: for face in vertex.adjacent_faces: total += face.face_point count += 1 avg_face_points.append(total/count) return avg_face_points
def get_avg_mid_edges(mesh: WingedMesh): avg_mid_edges = [] total = Vec3d.zero() count = 0 for vertex in mesh.vertices: for edge in vertex.edges: cp1 = edge.vertex.position cp2 = edge.next.vertex.position total += (cp1 + cp2) / 2.0 count += 1 avg_mid_edges .append(total/count) return avg_mid_edges
def create_new_points(mesh: WingedMesh): new_vertex_positions = [] for vertex in mesh.vertices: total = Vec3d.zero() count = 0 for face in vertex.adjacent_faces: total += face.face_point count += 1 avg_face_points = total / count total = Vec3d.zero() count = 0 for edge in vertex.edges: cp1 = edge.vertex.position cp2 = edge.next.vertex.position total += (cp1 + cp2) / 2.0 count += 1 avg_mid_edges = total / count n = len(list(vertex.adjacent_faces)) m1 = (n - 3) * vertex.position m2 = 2 * avg_mid_edges new_vertex_positions.append((avg_face_points + m2 + m1) / n) for i, vertex in enumerate(mesh.vertices): vertex.position = new_vertex_positions[i]
def reset(self): self.transform = Transform(Vec3d(0, 4, -15)) # self.transform.position.z = -10 self.target_object = Vec3d.zero()
def __init__(self): self.transform = Transform(Vec3d(0, 4, -15)) # self.transform.position.z = 12 self.target_object = Vec3d.zero()