I have a midpoint (x,y) and i need to find (in elegant and python style) a vertices of square with rotation for a given angle (t
) or random adding to my function a parameter t (angle), when t
is equal to r
(=random) the vertices are random located.
def get_square_plot(x, y, side):
return [(x-(side/2), y+(side/2)), (x+(side/2), y+(side/2)), (x-(side/2), y-(side/2)), (x-(side/2), y-(side/2))]
where x,y
are the coordinate of midpoint and side
the side of the square
print get_square_plot(0, 0, 10)
[(-5.0, 5.0), (5.0, 5.0), (-5.0, -5.0), (-5.0, -5.0)]