Skip to content

Instantly share code, notes, and snippets.

View nerdolo's full-sized avatar

nerdolo

  • Poznań, Poland
View GitHub Profile
@nerdolo
nerdolo / quadrangle to triangles
Created April 20, 2020 19:46
function for dividing quadrangle into two triangles that create it regardless of initial points order
import math
def matrix_det(mat): # mat - matrix
det, k_1, k_2 = 0, 1, 1
for i in range(3):
for j in range(3):
k_1 *= mat[(i + j) % 3][j % 3]
k_2 *= mat[-((i + j) % 3)][-(j % 3)]
det += k_1 - k_2
return det