Esempio n. 1
0
    def do(self):
        cache = context.application.cache
        for node in cache.nodes:
            transformation = Complete()

            translated_children = []
            for child in node.children:
                if isinstance(child, GLTransformationMixin) and isinstance(child.transformation, Translation):
                    if child.get_fixed():
                        translated_children = []
                        break
                    translated_children.append(child)
            if len(translated_children) == 0:
                continue

            mass, com = compute_center_of_mass(yield_particles(node))
            if mass == 0.0:
                continue

            transformation.t = com
            tensor = compute_inertia_tensor(yield_particles(node), com)
            transformation.r = default_rotation_matrix(tensor)
            CenterAlignBase.do(self, node, translated_children, transformation)