Example #1
0
// Left multiplies the current top of the matrix by the
// argument.
func (ms *MatStack) LeftMul(m mgl64.Mat4) {
	(*ms)[len(*ms)-1] = m.Mul4((*ms)[len(*ms)-1])
}
Example #2
0
func catmullRom(p1, p2, p3, p4 mgl64.Vec2, u float64) mgl64.Vec2 {
	var B mgl64.Mat4

	B.Set(0, 0, 1)
	B.Set(0, 1, -3)
	B.Set(0, 2, 3)
	B.Set(0, 3, -1)
	B.Set(1, 0, 4)
	B.Set(1, 1, 0)
	B.Set(1, 2, -6)
	B.Set(1, 3, 3)
	B.Set(2, 0, 1)
	B.Set(2, 1, 3)
	B.Set(2, 2, 3)
	B.Set(2, 3, -3)
	B.Set(3, 0, 0)
	B.Set(3, 1, 0)
	B.Set(3, 2, 0)
	B.Set(3, 3, 1)

	B = B.Mul(1.0 / 6.0)

	var pMat mgl64.Mat2x4

	pMat.Set(0, 0, p1.X())
	pMat.Set(1, 0, p1.Y())
	pMat.Set(0, 1, p2.X())
	pMat.Set(1, 1, p2.Y())
	pMat.Set(0, 2, p3.X())
	pMat.Set(1, 2, p3.Y())
	pMat.Set(0, 3, p4.X())
	pMat.Set(1, 3, p4.Y())

	return pMat.Mul4(B).Mul4x1(mgl64.Vec4{0, 1, 2 * u, 2 * u * u})
}