# get_square_vertices_calc

pyhelpers.geom.get_square_vertices_calc(ctr_x, ctr_y, side_length, rotation_theta=0)

Get the four vertices of a square given its centre and side length (by elementary calculation).

Parameters
• ctr_x (int or float) – x coordinate of a square centre

• ctr_y (int or float) – y coordinate of a square centre

• side_length (int or float) – side length of a square

• rotation_theta (int or float) – rotate (anticlockwise) the square by `rotation_theta` (in degree), defaults to `0`

Returns

vertices of the square as an array([ll, ul, ur, lr])

Return type

numpy.ndarray

Examples:

```>>> from pyhelpers.geom import get_square_vertices_calc

>>> ctr_1, ctr_2 = -5.9375, 56.8125
>>> side_len = 0.125

>>> vts = get_square_vertices_calc(ctr_1, ctr_2, side_len, rotation_theta=0)
>>> vts
array([[-6.   , 56.75 ],
[-6.   , 56.875],
[-5.875, 56.875],
[-5.875, 56.75 ]])

>>> # Rotate the square by 30° (anticlockwise)
>>> vts = get_square_vertices_calc(ctr_1, ctr_2, side_len, rotation_theta=30)
>>> vts
array([[-5.96037659, 56.72712341],
[-6.02287659, 56.83537659],
[-5.91462341, 56.89787659],
[-5.85212341, 56.78962341]])
```