calculate_square_boundaries(drone_position_x: float, drone_position_y: float, side_length: float) List[tuple]:ΒΆ

This function calculates the four extremes of a square perimeter, given the physical position of a drone and the length of the perimeter.

Args:
  • drone_position_x: The x-coordinate of the drone position.

  • drone_position_y: The y-coordinate of the drone position.

  • side_length: The length of the square perimeter.

Returns:

A list of four tuples, each tuple representing the coordinates of one of the extreme points of the square perimeter.

Example:

>>> calculate_square_boundaries(drone_position_x=50.0, drone_position_y=50.0, side_length=100.0)
[((0.0, 100.0), (100.0, 100.0), (0.0, 0.0), (100.0, 0.0))]
from math import floor

def calculate_square_boundaries(drone_position_x: float, drone_position_y: float, side_length: float) -> List[tuple]:

    half_side = side_length / 2.0

    drone_position_x = floor(drone_position_x)
    drone_position_y = floor(drone_position_y)

    upper_left = (drone_position_x - half_side, drone_position_y + half_side)
    upper_right = (drone_position_x + half_side, drone_position_y + half_side)
    lower_left = (drone_position_x - half_side, drone_position_y - half_side)
    lower_right = (drone_position_x + half_side, drone_position_y - half_side)

    return [upper_left, upper_right, lower_left, lower_right]