get_square_vertices
- pyhelpers.geom.get_square_vertices(ctr_x, ctr_y, side_length, rotation_theta=0)[source]
Get the four vertices of a square given its centre and side length.
See also [GEOM-GSV-1].
- Parameters:
ctr_x (int | float) – x coordinate of a square centre
ctr_y (int | float) – y coordinate of a square centre
side_length (int | float) – side length of a square
rotation_theta (int | float) – rotate (anticlockwise) the square by
rotation_theta
(in degree), defaults to0
- Returns:
vertices of the square as an array([ll, ul, ur, lr])
- Return type:
numpy.ndarray
Examples:
>>> from pyhelpers.geom import get_square_vertices >>> ctr_1, ctr_2 = -5.9375, 56.8125 >>> side_len = 0.125 >>> vts = get_square_vertices(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(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]])