Ejemplo n.º 1
0
    def __init__(self, body, vertices, offset):
        """body is the body to attach the poly to, verts is an array of
        cpVect's defining a convex hull with a counterclockwise winding, offset
        is the offset from the body's center of gravity in body local
        coordinates."""
        self._body = body
        verts = (vec2d * len(vertices))(*vertices)
#		for (i, vertex) in enumerate(vertices):
#			verts[i].x = vertex.x
#			verts[i].y = vertex.y
        print cp.cpMomentForPoly(body.mass, len(vertices), verts, offset)
        self._shape = cp.cpPolyShapeNew(body._body, len(vertices), verts, offset)
Ejemplo n.º 2
0
 def __init__(self, body, vertices, offset):
     """body is the body to attach the poly to, verts is an array of
     cpVect's defining a convex hull with a counterclockwise winding, offset
     is the offset from the body's center of gravity in body local
     coordinates."""
     self._body = body
     verts = (vec2d * len(vertices))(*vertices)
     #		for (i, vertex) in enumerate(vertices):
     #			verts[i].x = vertex.x
     #			verts[i].y = vertex.y
     print cp.cpMomentForPoly(body.mass, len(vertices), verts, offset)
     self._shape = cp.cpPolyShapeNew(body._body, len(vertices), verts,
                                     offset)
Ejemplo n.º 3
0
def moment_for_poly(mass, vertices,  offset):
    """Calculate the moment of inertia for a polygon"""
    verts = (Vec2d * len(vertices))
    verts = verts(Vec2d(0, 0))
    for (i, vertex) in enumerate(vertices):
        verts[i].x = vertex[0]
        verts[i].y = vertex[1]
    return cp.cpMomentForPoly(mass, len(verts), verts, offset)