vendredi 8 octobre 2021

how can I improve this if else statement?

for finding the direction of ray in cartesian plane

def direction(self):
        if 180>self.angle>90:
            return (-1,+1)
        elif 90>self.angle>0:
            return (1,1)
        elif 0>self.angle>-90:
            return (1,-1)
        elif -90>self.angle>-180:
            return (-1,-1)

thus looks kinda bulky is there a simpler way out?

Aucun commentaire:

Enregistrer un commentaire