aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorchriscamacho <chriscamacho@users.noreply.github.com>2019-08-09 16:04:52 +0100
committerRay <raysan5@gmail.com>2019-08-09 17:04:52 +0200
commit6f2f09947f5456cefb3d91d3f667f4d72fa55be6 (patch)
tree91f053178f1c384a2c59120173dec3e71e8f28e3 /src
parente6e48675cc8c8a2a9abe7bae257054f529da419a (diff)
downloadraylib-6f2f09947f5456cefb3d91d3f667f4d72fa55be6.tar.gz
raylib-6f2f09947f5456cefb3d91d3f667f4d72fa55be6.zip
addition to raylib to create matrix from 3 euler angles (#938)
Diffstat (limited to 'src')
-rw-r--r--src/raymath.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/raymath.h b/src/raymath.h
index d866ad82..12ea76b4 100644
--- a/src/raymath.h
+++ b/src/raymath.h
@@ -56,7 +56,7 @@
#if defined(RAYMATH_IMPLEMENTATION)
#if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED)
#define RMDEF __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll).
- #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
+ #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED)
#define RMDEF __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll)
#else
#define RMDEF extern inline // Provide external definition
@@ -113,7 +113,7 @@
float y;
float z;
} Vector3;
-
+
// Quaternion type
typedef struct Quaternion {
float x;
@@ -794,6 +794,33 @@ RMDEF Matrix MatrixRotate(Vector3 axis, float angle)
return result;
}
+// Returns xyz-rotation matrix (angles in radians)
+RMDEF Matrix MatrixRotateXYZ(Vector3 ang)
+{
+ Matrix result = MatrixIdentity();
+
+ float cosz = cosf(-ang.z);
+ float sinz = sinf(-ang.z);
+ float cosy = cosf(-ang.y);
+ float siny = sinf(-ang.y);
+ float cosx = cosf(-ang.x);
+ float sinx = sinf(-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;
+}
+
// Returns x-rotation matrix (angle in radians)
RMDEF Matrix MatrixRotateX(float angle)
{