def getCenter(self): """Return the center of the material form.""" center=MaterialPoint.createFromform.center x,y=center position=Vector(x,y,color=mycolors.GREEN) point_motion=Motion() for point in self.points: point_motion+=point.getMotion() material_center=MaterialPoint(point_motion) material_center.setPosition(position) return material_center
def crossMaterialForm(self,other): """Return the material point of intersection between two material forms.""" f1=self.getForm() f2=other.getForm() points=f1.crossForm(f2) points=[MaterialPoint.createFromPoint(point) for point in points] return points
def showMotion(self,surface): """Show the motion on a surface.""" form=self.getForm() center=form.center() x,y=center position=Vector(x,y,color=mycolors.GREEN) point_motion=Motion() for point in self.points: point_motion+=point.getMotion() material_center=MaterialPoint(point_motion) material_center.setPosition(position) material_center.showMotion(surface)
def createFromForm(form): """Create a material form using a Form instance.""" return MaterialForm( [MaterialPoint.createFromAbstract(point) for point in form.points])
def getCenter(self): """Return the material center of the form.""" return MaterialPoint.average(self.points)
def crossMaterialForm(self, other): """Return the material point of intersection between two material forms.""" f1 = self.abstract f2 = other.abstract points = f1.crossForm(f2) return [MaterialPoint.createFromAbstract(point) for point in points]
def null(d=2): """Return the neutral element of the material segment.""" return MaterialSegment([MaterialPoint.null(d) for i in range(2)])
def random(corners=[-1,-1,1,1]): """Return a random material segment within the given corners.""" return MaterialSegment([MaterialPoint.random(corners) for i in range(2)])
def createFromForm(form,forces=[]): """Create a material form using a Form instance.""" material_points=[MaterialPoint.createFromPoint(point,forces) for point in form.getPoints()] return MaterialForm(material_points)
def random(corners=[-1,-1,1,1],number=5): """Create a random material form.""" points=[MaterialPoint.random(min,max) for n in range(number)] return MaterialForm(points)