Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Similar Triangles - some math solution in Clear category for Similar Triangles by KirillovaV
import math
from typing import List, Tuple
Coords = List[Tuple[int, int]]
def side_length(c: Coords):
side_1 = math.sqrt((c[1][0] - c[0][0]) ** 2 + (c[1][1] - c[0][1]) ** 2)
side_2 = math.sqrt((c[2][0] - c[1][0]) ** 2 + (c[2][1] - c[1][1]) ** 2)
side_3 = math.sqrt((c[2][0] - c[0][0]) ** 2 + (c[2][1] - c[0][1]) ** 2)
return sorted((side_1, side_2, side_3))
def similar_triangles(coords_1: Coords, coords_2: Coords) -> bool:
tr_1 = side_length(coords_1)
tr_2 = side_length(coords_2)
return tr_1[0]/tr_2[0] == tr_1[1]/tr_2[1] == tr_1[2]/tr_2[2]
Jan. 21, 2021
Comments: