about summary refs log tree commit diff homepage
path: root/utils/hacks/TreeGraphs/Graphics/Geometry/mat2.py
blob: 05320d5e0557f42df12ffe2f149cf7eaf5dc3d94 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import vec2

def det(m):
	((m00,m01),(m10,m11))= m
	
	return m00*m11 - m01*m10

def mul(a,b):
	b_trans= zip(* b)
	return tuple([transmulvec2(b_trans, a_r) for a_r in a])

	# multiple vector v by a transposed matrix
def transmulvec2(m_trans,v):
	return tuple([vec2.dot(v, m_c) for m_c in m_trans])

def mulvec2(m,v):
	return transmulvec2(zip(* m), v)

def mulN(m,N):
	return tuple([vec2.mulN(v,N) for v in m])