From cdb9bd006d80e7c7cf0d442d1182abef9f481841 Mon Sep 17 00:00:00 2001 From: Holmqvist1990 Date: Sat, 2 Jul 2022 17:22:46 +0200 Subject: [PATCH] added MatrixRotateXYZ --- raylib/raymath.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/raylib/raymath.go b/raylib/raymath.go index e1b3427..0d4bbae 100644 --- a/raylib/raymath.go +++ b/raylib/raymath.go @@ -653,6 +653,32 @@ func MatrixRotateZ(angle float32) Matrix { return result } +// MatrixRotateXYZ - Get xyz-rotation matrix (angles in radians) +func MatrixRotateXYZ(ang Vector3) Matrix { + result := MatrixIdentity() + + cosz := float32(math.Cos(float64(-ang.Z))) + sinz := float32(math.Sin(float64(-ang.Z))) + cosy := float32(math.Cos(float64(-ang.Y))) + siny := float32(math.Sin(float64(-ang.Y))) + cosx := float32(math.Cos(float64(-ang.X))) + sinx := float32(math.Sin(float64(-ang.X))) + + result.M0 = cosz * cosy + result.M4 = (cosz * siny * sinx) - (sinz * cosx) + result.M8 = (cosz * siny * cosx) + (sinz * sinx) + + result.M1 = sinz * cosy + result.M5 = (sinz * siny * sinx) + (cosz * cosx) + result.M9 = (sinz * siny * cosx) - (cosz * sinx) + + result.M2 = -siny + result.M6 = cosy * sinx + result.M10 = cosy * cosx + + return result +} + // MatrixScale - Returns scaling matrix func MatrixScale(x, y, z float32) Matrix { result := NewMatrix(