Project/calculation_tools.py
def staticStability(robot):
    """
    Return true is the center of mass is included in the support polygon, else false

    :param robot: robot object
    :return: Boolean
    """
    com = getCOM(robot)
    polygonCoordinates = getSupportPolygon(robot)
    n = len(polygonCoordinates)
    included = False

    if n > 2:
        # using ray casting algo
        included = isPointInside(com[:-1], polygonCoordinates)
    elif n == 2:
        ab = math.sqrt((polygonCoordinates[0][0] - polygonCoordinates[1][0]) ** 2 + (
                polygonCoordinates[0][1] - polygonCoordinates[1][1]) ** 2)
        ac = math.sqrt((polygonCoordinates[0][0] - com[0]) ** 2 + (polygonCoordinates[0][1] - com[1]) ** 2)
        cb = math.sqrt((com[0] - polygonCoordinates[1][0]) ** 2 + (com[1] - polygonCoordinates[1][1]) ** 2)
        if ac + cb == ab:
            included = True
    elif n == 1:
        if com[:-1] == polygonCoordinates[:-1]:
            included = True

    return included

    Return true is the center of mass is included in the support polygon, else false

    :param robot: robot object
    :return: Boolean
    
Return true is the center of mass is included in the support polygon, else false
Return true is the center of mass is included in the support polygon else false
def staticStability(robot):
    com = getCOM(robot)
    polygonCoordinates = getSupportPolygon(robot)
    n = len(polygonCoordinates)
    included = False
    if n > 2:
        included = isPointInside(com[:-1], polygonCoordinates)
    elif n == 2:
        ab = math.sqrt((polygonCoordinates[0][0] - polygonCoordinates[1][0]) ** 2 + (
                polygonCoordinates[0][1] - polygonCoordinates[1][1]) ** 2)
        ac = math.sqrt((polygonCoordinates[0][0] - com[0]) ** 2 + (polygonCoordinates[0][1] - com[1]) ** 2)
        cb = math.sqrt((com[0] - polygonCoordinates[1][0]) ** 2 + (com[1] - polygonCoordinates[1][1]) ** 2)
        if ac + cb == ab:
            included = True
    elif n == 1:
        if com[:-1] == polygonCoordinates[:-1]:
            included = True
    return included
def staticStability ( robot ) : com = getCOM ( robot ) polygonCoordinates = getSupportPolygon ( robot ) n = len ( polygonCoordinates ) included = False if n > 2 : included = isPointInside ( com [ : - 1 ] , polygonCoordinates ) elif n == 2 : ab = math . sqrt ( ( polygonCoordinates [ 0 ] [ 0 ] - polygonCoordinates [ 1 ] [ 0 ] ) ** 2 + ( polygonCoordinates [ 0 ] [ 1 ] - polygonCoordinates [ 1 ] [ 1 ] ) ** 2 ) ac = math . sqrt ( ( polygonCoordinates [ 0 ] [ 0 ] - com [ 0 ] ) ** 2 + ( polygonCoordinates [ 0 ] [ 1 ] - com [ 1 ] ) ** 2 ) cb = math . sqrt ( ( com [ 0 ] - polygonCoordinates [ 1 ] [ 0 ] ) ** 2 + ( com [ 1 ] - polygonCoordinates [ 1 ] [ 1 ] ) ** 2 ) if ac + cb == ab : included = True elif n == 1 : if com [ : - 1 ] == polygonCoordinates [ : - 1 ] : included = True return included
Return true is the center of mass is included in the support polygon, else false
Return true is the center of mass is included in the support polygon else false
"""
    Return true is the center of mass is included in the support polygon, else false

    :param robot: robot object
    :return: Boolean
    """ # using ray casting algo
None
robot
None