def movepoints(self): for object in self.objects: for point in object: # Gets the vector from the old pos to the new pos # Multiplies it by the friction value to act as air resistance and friction velocity = (point - point.old) * self.friction self.evManager.push(MoveEvent(velocity.length())) # Sets the new old position the current new position point.old = Vectors.Vector3d(*point.list()) # Gets the new position. Adds the gravity vector and mulplies by the nodes w value # A W value of 1 means that the point is normal and acts normally # A W value of 0 means that the point is 'pinned' and can't move newposition = point + (velocity + self.grav) * point.w # Sets the new node position point.x = newposition.x point.y = newposition.y point.z = newposition.z
def findCentre(self): meanX = sum([node.x for node in self.nodes]) / len(self.nodes) meanY = sum([node.y for node in self.nodes]) / len(self.nodes) meanZ = sum([node.z for node in self.nodes]) / len(self.nodes) return Vectors.Vector3d(meanX, meanY, meanZ)