# A dictionary complements an if, elif, else block

## OLD CODE (2002?)

if _relrotation > 0.0 and _relrotation < 90.0:

    _caseno = "Case 1"

    _xflg = 1

    _yflg = 1

elif _relrotation > 90.0 and _relrotation < 180.0:

    _caseno = "Case 2"

    if _hssflgweb == "Short Side":

        _xflg = -1

        _yflg = -1

    else:

        _xflg = -1

        _yflg = 1

elif _relrotation > 180.0 and _relrotation < 270.0:

    _caseno = "Case 3"

    if _hssflgweb == "Short Side":

        _xflg = -1

        _yflg = 1

    else:

        _xflg = 1

        _yflg = -1 

elif _relrotation > 270.0 and _relrotation < 360.0:

    _caseno = "Case 4"

    if _hssflgweb == "Short Side":

        _xflg = 1

        _yflg = -1

    else:

        _xflg = -1

        _yflg = -1

 

if case_no == "Case 1" or case_no == "Case 3":

    rot_argument = [rel_rotation, 0.0, 0.0]

elif case_no == "Case 2" or case_no == "Case 4":

    rot_argument = [180.0 - rel_rotation, 0.0, 180.0]

if hss_flg_web == "Long Side":

    rot_argument[0] = 180.0 - rot_argument[0]

    rot_argument[2] = rot_argument[2] + 180.0

 

## NEW CODE (11/07)

 

caseDict = {"Case 1": {"Long Side": (1,1,(180.0-relRot, 0.0, 180.0)), \

                       "Short Side": (1,1,(relRot, 0.0, 0.0))}, \

            "Case 2": {"Long Side": (-1,1,(relRot, 0.0, 0.0)), \

                       "Short Side": (-1,-1,(180.0-relRot, 0.0, 180.0))}, \

            "Case 3": {"Long Side": (1,-1,(180.0-relRot, 0.0, 180.0)), \

                       "Short Side": (-1,1,(relRot, 0.0, 0.0))}, \

            "Case 4": {"Long Side": (-1,-1,(relRot, 0.0, 0.0)), \

                       "Short Side": (1,-1,(180.0-relRot, 0.0, 180.0))}

            }

 

if 0.0 < relRot <= 90.0:

    caseno = "Case 1"

elif 90.0 < relRot <= 180.0:

    caseno = "Case 2"

elif 180.0 < relRot <= 270.0:

    caseno = "Case 3"

else:

    caseno = "Case 4"

 

self.xflg, self.yflg, self.rot = caseDict[caseno][flgweb]