Here is my long if statement:
if i % 2 == 1 or i == 0:
if x1 > x:
ny = y + ceil(shift * (i / 2))
ny1 = y1 + ceil(shift * (i / 2))
elif x1 == x:
ny = y
ny1 = y1
elif x1 < x:
ny = y - ceil(shift * (i / 2))
ny1 = y1 - ceil(shift * (i / 2))
if y1 > y:
nx = x - ceil(shift * (i / 2))
nx1 = x1 - ceil(shift * (i / 2))
elif y1 == y:
nx = x
nx1 = x1
elif y1 < y:
nx = x + ceil(shift * (i / 2))
nx1 = x1 + ceil(shift * (i / 2))
else:
if x1 > x:
ny = y - ceil(shift * (i / 2))
ny1 = y1 - ceil(shift * (i / 2))
elif x1 == x:
ny = y
ny1 = y1
elif x1 < x:
ny = y + ceil(shift * (i / 2))
ny1 = y1 + ceil(shift * (i / 2))
if y1 > y:
nx = x + ceil(shift * (i / 2))
nx1 = x1 + ceil(shift * (i / 2))
elif y1 == y:
nx = x
nx1 = x1
elif y1 < y:
nx = x - ceil(shift * (i / 2))
nx1 = x1 - ceil(shift * (i / 2))
return nx, ny, nx1, ny1
I'm not sure if it's possible to just convert this whole thing into a simple equation. However, if not, is there any possible way to only have the first large if statement and make the sign in ny = y + ceil(shift * (i / 2))
be plus if i % 2 == 1 or i == 0
and minus else
?
Aucun commentaire:
Enregistrer un commentaire