From bec6bdca6aa58a6ec510d1e796ae0444fa5ddd3b Mon Sep 17 00:00:00 2001 From: faiface <faiface@ksp.sk> Date: Sun, 19 Mar 2017 00:08:46 +0100 Subject: [PATCH] add Matrix.Chained --- geometry.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/geometry.go b/geometry.go index ad63f99..12a324f 100644 --- a/geometry.go +++ b/geometry.go @@ -284,6 +284,14 @@ func (m Matrix) Rotated(around Vec, angle float64) Matrix { return Matrix(m3) } +// Chained adds another Matrix to this one. All tranformations by the next Matrix will be applied +// after the transformations of this Matrix. +func (m Matrix) Chained(next Matrix) Matrix { + m3 := mgl64.Mat3(m) + m3 = mgl64.Mat3(next).Mul3(m3) + return Matrix(m3) +} + // Project applies all transformations added to the Matrix to a vector u and returns the result. // // Time complexity is O(1). -- GitLab