// AssignMat3x3 assigns a 3x3 sub-matrix and sets the rest of the matrix to the ident value.
179255
func (mat *T) AssignMat3x3(m *mat3.T) *T {
	*mat = T{
		vec4.T{m[0][0], m[1][0], m[2][0], 0},
		vec4.T{m[0][1], m[1][1], m[2][1], 0},
		vec4.T{m[0][2], m[1][2], m[2][2], 0},
		vec4.T{0, 0, 0, 1},
	}
	return mat
}
1111971
func (m1 Mat4x3) Mul3x2(m2 Mat3x2) Mat4x2 {
	return Mat4x2{
		m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2],
		m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2],
		m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2],
		m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2],
		m1[0]*m2[3] + m1[4]*m2[4] + m1[8]*m2[5],
		m1[1]*m2[3] + m1[5]*m2[4] + m1[9]*m2[5],
		m1[2]*m2[3] + m1[6]*m2[4] + m1[10]*m2[5],
		m1[3]*m2[3] + m1[7]*m2[4] + m1[11]*m2[5],
	}
}
1079517
func Mat4Normal(m Mat4) Mat3 {
	n := m.Inv().Transpose()
	return Mat3{n[0], n[1], n[2], n[4], n[5], n[6], n[8], n[9], n[10]}
}
96110
func (m1 Mat3) Add(m2 Mat3) Mat3 {
	return Mat3{m1[0] + m2[0], m1[1] + m2[1], m1[2] + m2[2], m1[3] + m2[3], m1[4] + m2[4], m1[5] + m2[5], m1[6] + m2[6], m1[7] + m2[7], m1[8] + m2[8]}
}
378413
func Sub(a, b *T) T {
	if a[3] == b[3] {
		return T{a[0] - b[0], a[1] - b[1], a[2] - b[2], 1}
	} else {
		a3 := a.Vec3DividedByW()
		b3 := b.Vec3DividedByW()
		return T{a3[0] - b3[0], a3[1] - b3[1], a3[2] - b3[2], 1}
	}
}
1006855
func (mat *T) Transpose3x3() *T {
	swap(&mat[1][0], &mat[0][1])
	swap(&mat[2][0], &mat[0][2])
	swap(&mat[2][1], &mat[1][2])
	return mat
}
1147190
func (m1 Mat3x2) Mul2x3(m2 Mat2x3) Mat3 {
	return Mat3{
		m1[0]*m2[0] + m1[3]*m2[1],
		m1[1]*m2[0] + m1[4]*m2[1],
		m1[2]*m2[0] + m1[5]*m2[1],
		m1[0]*m2[2] + m1[3]*m2[3],
		m1[1]*m2[2] + m1[4]*m2[3],
		m1[2]*m2[2] + m1[5]*m2[3],
		m1[0]*m2[4] + m1[3]*m2[5],
		m1[1]*m2[4] + m1[4]*m2[5],
		m1[2]*m2[4] + m1[5]*m2[5],
	}
}
443901
func (m *Mat3x2) SetCol(col int, v Vec3) {
	m[col*3+0], m[col*3+1], m[col*3+2] = v[0], v[1], v[2]
}
191505
func (m1 Mat2x3) Mul3(m2 Mat3) Mat2x3 {
	return Mat2x3{
		m1[0]*m2[0] + m1[2]*m2[1] + m1[4]*m2[2],
		m1[1]*m2[0] + m1[3]*m2[1] + m1[5]*m2[2],
		m1[0]*m2[3] + m1[2]*m2[4] + m1[4]*m2[5],
		m1[1]*m2[3] + m1[3]*m2[4] + m1[5]*m2[5],
		m1[0]*m2[6] + m1[2]*m2[7] + m1[4]*m2[8],
		m1[1]*m2[6] + m1[3]*m2[7] + m1[5]*m2[8],
	}
}
1282381
func (m1 Mat3x2) Add(m2 Mat3x2) Mat3x2 {
	return Mat3x2{m1[0] + m2[0], m1[1] + m2[1], m1[2] + m2[2], m1[3] + m2[3], m1[4] + m2[4], m1[5] + m2[5]}
}
1104501
func (cr *Context) SetMatrix(matrix *Matrix) {
	C.cairo_set_matrix(cr.Ptr, (*C.cairo_matrix_t)(unsafe.Pointer(matrix)))
	if err := cr.status(); err != nil {
		panic(err)
	}
}
1331183
func (m1 Mat4x3) Mul3x4(m2 Mat3x4) Mat4 {
	return Mat4{
		m1[0]*m2[0] + m1[4]*m2[1] + m1[8]*m2[2],
		m1[1]*m2[0] + m1[5]*m2[1] + m1[9]*m2[2],
		m1[2]*m2[0] + m1[6]*m2[1] + m1[10]*m2[2],
		m1[3]*m2[0] + m1[7]*m2[1] + m1[11]*m2[2],
		m1[0]*m2[3] + m1[4]*m2[4] + m1[8]*m2[5],
		m1[1]*m2[3] + m1[5]*m2[4] + m1[9]*m2[5],
		m1[2]*m2[3] + m1[6]*m2[4] + m1[10]*m2[5],
		m1[3]*m2[3] + m1[7]*m2[4] + m1[11]*m2[5],
		m1[0]*m2[6] + m1[4]*m2[7] + m1[8]*m2[8],
		m1[1]*m2[6] + m1[5]*m2[7] + m1[9]*m2[8],
		m1[2]*m2[6] + m1[6]*m2[7] + m1[10]*m2[8],
		m1[3]*m2[6] + m1[7]*m2[7] + m1[11]*m2[8],
		m1[0]*m2[9] + m1[4]*m2[10] + m1[8]*m2[11],
		m1[1]*m2[9] + m1[5]*m2[10] + m1[9]*m2[11],
		m1[2]*m2[9] + m1[6]*m2[10] + m1[10]*m2[11],
		m1[3]*m2[9] + m1[7]*m2[10] + m1[11]*m2[11],
	}
}
88371
func (m *Mat4x3) SetCol(col int, v Vec4) {
	m[col*4+0], m[col*4+1], m[col*4+2], m[col*4+3] = v[0], v[1], v[2], v[3]
}
1218749
func Mat4x3FromRows(row0, row1, row2, row3 Vec3) Mat4x3 {
	return Mat4x3{row0[0], row1[0], row2[0], row3[0], row0[1], row1[1], row2[1], row3[1], row0[2], row1[2], row2[2], row3[2]}
}
105063
func Mat2x3FromRows(row0, row1 Vec3) Mat2x3 {
	return Mat2x3{row0[0], row1[0], row0[1], row1[1], row0[2], row1[2]}
}
969823
func Assign(form interface{}, data map[string]interface{}) {
	typ := reflect.TypeOf(form)
	val := reflect.ValueOf(form)

	if typ.Kind() == reflect.Ptr {
		typ = typ.Elem()
		val = val.Elem()
	}

	for i := 0; i < typ.NumField(); i++ {
		field := typ.Field(i)

		fieldName := field.Tag.Get("form")
		// Allow ignored fields in the struct
		if fieldName == "-" {
			continue
		} else if len(fieldName) == 0 {
			fieldName = com.ToSnakeCase(field.Name)
		}

		data[fieldName] = val.Field(i).Interface()
	}
}
1307617
func (vec *T) AssignVec3(v *vec3.T) *T {
	vec[0] = v[0]
	vec[1] = v[1]
	vec[2] = v[2]
	vec[3] = 1
	return vec
}