Last active
March 16, 2024 05:58
-
-
Save amirsinaa/9735fde36f3829ebb2358ae6b9a64c36 to your computer and use it in GitHub Desktop.
Python code that takes three sets of coordinates, representing three vertices of a rectangle, and calculates the fourth vertex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def find_alis_fourth_rectangle_vertex(coord1, coord2, coord3): | |
x_coords = [coord1[0], coord2[0], coord3[0]] | |
y_coords = [coord1[1], coord2[1], coord3[1]] | |
fourth_x = None | |
fourth_y = None | |
for x in x_coords: | |
if x_coords.count(x) == 1: | |
fourth_x = x | |
break | |
for y in y_coords: | |
if y_coords.count(y) == 1: | |
fourth_y = y | |
break | |
return fourth_x, fourth_y | |
print("Enter the coordinates of three vertices of the rectangle:") | |
coords1 = list(map(float, input().split())) | |
coords2 = list(map(float, input().split())) | |
coords3 = list(map(float, input().split())) | |
coord1 = (coords1[0], coords1[1]) | |
coord2 = (coords2[0], coords2[1]) | |
coord3 = (coords3[0], coords3[1]) | |
fourth_vertex = find_alis_fourth_rectangle_vertex(coord1, coord2, coord3) | |
print(fourth_vertex) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment