Mercurial
annotate third_party/raylib/include/raymath.h @ 279:b3b547563ec7
Add Google connector service and agent wiki
Implement the C/Seobeo Google Drive and Gmail connector with encrypted OAuth storage, Zenbu authentication, browser testing, AI tool discovery, chunked HTTP decoding, and Bazel coverage. Consolidate repository guidance into progressive wiki documentation and enforce arena-first allocation for new first-party C code.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 84c338fd-0939-4bb3-b7f3-1062eb213e5d
| author | MrJuneJune <me@mrjunejune.com> |
|---|---|
| date | Mon, 17 Aug 2026 22:22:36 -0700 |
| parents | b55c22cff335 |
| children |
| rev | line source |
|---|---|
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1 /********************************************************************************************** |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3 * raymath v2.0 - Math functions to work with Vector2, Vector3, Matrix and Quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
4 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
5 * CONVENTIONS: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
6 * - Matrix structure is defined as row-major (memory layout) but parameters naming AND all |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
7 * math operations performed by the library consider the structure as it was column-major |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
8 * It is like transposed versions of the matrices are used for all the maths |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
9 * It benefits some functions making them cache-friendly and also avoids matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
10 * transpositions sometimes required by OpenGL |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
11 * Example: In memory order, row0 is [m0 m4 m8 m12] but in semantic math row0 is [m0 m1 m2 m3] |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
12 * - Functions are always self-contained, no function use another raymath function inside, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
13 * required code is directly re-implemented inside |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
14 * - Functions input parameters are always received by value (2 unavoidable exceptions) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
15 * - Functions use always a "result" variable for return (except C++ operators) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
16 * - Functions are always defined inline |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
17 * - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience) |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
18 * - No compound literals used to make sure the library is compatible with C++ |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
19 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
20 * CONFIGURATION: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
21 * #define RAYMATH_IMPLEMENTATION |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
22 * Generates the implementation of the library into the included file |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
23 * If not defined, the library is in header only mode and can be included in other headers |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
24 * or source files without problems. But only ONE file should hold the implementation |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
25 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
26 * #define RAYMATH_STATIC_INLINE |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
27 * Define static inline functions code, so #include header suffices for use |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
28 * This may use up lots of memory |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
29 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
30 * #define RAYMATH_DISABLE_CPP_OPERATORS |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
31 * Disables C++ operator overloads for raymath types. |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
32 * |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
33 * #define RAYMATH_USE_SIMD_INTRINSICS 1 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
34 * Try to enable SIMD intrinsics for MatrixMultiply() |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
35 * Note that users enabling it must be aware of the target platform where application will |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
36 * run to support the selected SIMD intrinsic, for now, only SSE is supported |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
37 * |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
38 * LICENSE: zlib/libpng |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
39 * |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
40 * Copyright (c) 2015-2026 Ramon Santamaria (@raysan5) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
41 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
42 * This software is provided "as-is", without any express or implied warranty. In no event |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
43 * will the authors be held liable for any damages arising from the use of this software. |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
44 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
45 * Permission is granted to anyone to use this software for any purpose, including commercial |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
46 * applications, and to alter it and redistribute it freely, subject to the following restrictions: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
47 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
48 * 1. The origin of this software must not be misrepresented; you must not claim that you |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
49 * wrote the original software. If you use this software in a product, an acknowledgment |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
50 * in the product documentation would be appreciated but is not required. |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
51 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
52 * 2. Altered source versions must be plainly marked as such, and must not be misrepresented |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
53 * as being the original software. |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
54 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
55 * 3. This notice may not be removed or altered from any source distribution. |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
56 * |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
57 **********************************************************************************************/ |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
58 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
59 #ifndef RAYMATH_H |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
60 #define RAYMATH_H |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
61 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
62 #if defined(RAYMATH_IMPLEMENTATION) && defined(RAYMATH_STATIC_INLINE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
63 #error "Specifying both RAYMATH_IMPLEMENTATION and RAYMATH_STATIC_INLINE is contradictory" |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
64 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
65 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
66 // Function specifiers definition |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
67 #if defined(RAYMATH_IMPLEMENTATION) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
68 #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
69 #define RMAPI __declspec(dllexport) extern inline // Building raylib as a Win32 shared library (.dll) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
70 #elif defined(BUILD_LIBTYPE_SHARED) |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
71 #define RMAPI __attribute__((visibility("default"))) // Building raylib as a Unix shared library (.so/.dylib) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
72 #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
73 #define RMAPI __declspec(dllimport) // Using raylib as a Win32 shared library (.dll) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
74 #else |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
75 #define RMAPI extern inline // Provide external definition |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
76 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
77 #elif defined(RAYMATH_STATIC_INLINE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
78 #define RMAPI static inline // Functions may be inlined, no external out-of-line definition |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
79 #else |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
80 #if defined(__TINYC__) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
81 #define RMAPI static inline // plain inline not supported by tinycc (See issue #435) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
82 #else |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
83 #define RMAPI inline // Functions may be inlined or external definition used |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
84 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
85 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
86 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
87 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
88 // Defines and Macros |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
89 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
90 #ifndef PI |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
91 #define PI 3.14159265358979323846f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
92 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
93 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
94 #ifndef EPSILON |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
95 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
96 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
97 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
98 #ifndef DEG2RAD |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
99 #define DEG2RAD (PI/180.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
100 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
101 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
102 #ifndef RAD2DEG |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
103 #define RAD2DEG (180.0f/PI) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
104 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
105 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
106 // Get float vector for Matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
107 #ifndef MatrixToFloat |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
108 #define MatrixToFloat(mat) (MatrixToFloatV(mat).v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
109 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
110 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
111 // Get float vector for Vector3 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
112 #ifndef Vector3ToFloat |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
113 #define Vector3ToFloat(vec) (Vector3ToFloatV(vec).v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
114 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
115 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
116 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
117 // Types and Structures Definition |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
118 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
119 #if !defined(RL_VECTOR2_TYPE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
120 // Vector2 type |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
121 typedef struct Vector2 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
122 float x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
123 float y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
124 } Vector2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
125 #define RL_VECTOR2_TYPE |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
126 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
127 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
128 #if !defined(RL_VECTOR3_TYPE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
129 // Vector3 type |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
130 typedef struct Vector3 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
131 float x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
132 float y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
133 float z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
134 } Vector3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
135 #define RL_VECTOR3_TYPE |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
136 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
137 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
138 #if !defined(RL_VECTOR4_TYPE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
139 // Vector4 type |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
140 typedef struct Vector4 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
141 float x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
142 float y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
143 float z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
144 float w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
145 } Vector4; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
146 #define RL_VECTOR4_TYPE |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
147 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
148 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
149 #if !defined(RL_QUATERNION_TYPE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
150 // Quaternion type |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
151 typedef Vector4 Quaternion; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
152 #define RL_QUATERNION_TYPE |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
153 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
154 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
155 #if !defined(RL_MATRIX_TYPE) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
156 // Matrix type (OpenGL style 4x4 - right handed, column major) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
157 typedef struct Matrix { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
158 float m0, m4, m8, m12; // Matrix first row (4 components) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
159 float m1, m5, m9, m13; // Matrix second row (4 components) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
160 float m2, m6, m10, m14; // Matrix third row (4 components) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
161 float m3, m7, m11, m15; // Matrix fourth row (4 components) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
162 } Matrix; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
163 #define RL_MATRIX_TYPE |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
164 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
165 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
166 // NOTE: Helper types to be used instead of array return types for *ToFloat functions |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
167 #if !defined(RL_FLOAT3_TYPE) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
168 typedef struct float3 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
169 float v[3]; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
170 } float3; |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
171 #define RL_FLOAT3_TYPE |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
172 #endif |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
173 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
174 #if !defined(RL_FLOAT16_TYPE) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
175 typedef struct float16 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
176 float v[16]; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
177 } float16; |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
178 #define RL_FLOAT16_TYPE |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
179 #endif |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
180 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
181 #include <math.h> // Required for: sinf(), cosf(), tan(), atan2f(), sqrtf(), floor(), fminf(), fmaxf(), fabsf() |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
182 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
183 #if RAYMATH_USE_SIMD_INTRINSICS |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
184 // SIMD is used on the most costly raymath function MatrixMultiply() |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
185 // NOTE: Only SSE intrinsics support implemented |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
186 // TODO: Consider support for other SIMD intrinsics: |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
187 // - SSEx, AVX, AVX2, FMA, NEON, RVV |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
188 /* |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
189 #if defined(__SSE4_2__) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
190 #include <nmmintrin.h> |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
191 #define RAYMATH_SSE42_ENABLED |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
192 #elif defined(__SSE4_1__) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
193 #include <smmintrin.h> |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
194 #define RAYMATH_SSE41_ENABLED |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
195 #elif defined(__SSSE3__) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
196 #include <tmmintrin.h> |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
197 #define RAYMATH_SSSE3_ENABLED |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
198 #elif defined(__SSE3__) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
199 #include <pmmintrin.h> |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
200 #define RAYMATH_SSE3_ENABLED |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
201 #elif defined(__SSE2__) || (defined(_M_AMD64) || defined(_M_X64)) // SSE2 x64 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
202 #include <emmintrin.h> |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
203 #define RAYMATH_SSE2_ENABLED |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
204 #endif |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
205 */ |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
206 #if defined(__SSE__) || defined(_M_X64) || (defined(_M_IX86_FP) && (_M_IX86_FP >= 1)) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
207 #include <xmmintrin.h> |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
208 #define RAYMATH_SSE_ENABLED |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
209 #endif |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
210 #endif |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
211 |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
212 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
213 // Module Functions Definition - Utils math |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
214 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
215 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
216 // Clamp float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
217 RMAPI float Clamp(float value, float min, float max) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
218 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
219 float result = (value < min)? min : value; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
220 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
221 if (result > max) result = max; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
222 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
223 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
224 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
225 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
226 // Calculate linear interpolation between two floats |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
227 RMAPI float Lerp(float start, float end, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
228 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
229 float result = start + amount*(end - start); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
230 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
231 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
232 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
233 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
234 // Normalize input value within input range |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
235 RMAPI float Normalize(float value, float start, float end) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
236 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
237 float result = (value - start)/(end - start); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
238 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
239 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
240 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
241 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
242 // Remap input value within input range to output range |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
243 RMAPI float Remap(float value, float inputStart, float inputEnd, float outputStart, float outputEnd) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
244 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
245 float result = (value - inputStart)/(inputEnd - inputStart)*(outputEnd - outputStart) + outputStart; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
246 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
247 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
248 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
249 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
250 // Wrap input value from min to max |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
251 RMAPI float Wrap(float value, float min, float max) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
252 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
253 float result = value - (max - min)*floorf((value - min)/(max - min)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
254 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
255 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
256 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
257 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
258 // Check whether two given floats are almost equal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
259 RMAPI int FloatEquals(float x, float y) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
260 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
261 #if !defined(EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
262 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
263 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
264 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
265 int result = (fabsf(x - y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(x), fabsf(y)))); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
266 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
267 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
268 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
269 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
270 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
271 // Module Functions Definition - Vector2 math |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
272 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
273 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
274 // Vector with components value 0.0f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
275 RMAPI Vector2 Vector2Zero(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
276 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
277 Vector2 result = { 0.0f, 0.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
278 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
279 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
280 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
281 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
282 // Vector with components value 1.0f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
283 RMAPI Vector2 Vector2One(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
284 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
285 Vector2 result = { 1.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
286 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
287 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
288 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
289 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
290 // Add two vectors (v1 + v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
291 RMAPI Vector2 Vector2Add(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
292 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
293 Vector2 result = { v1.x + v2.x, v1.y + v2.y }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
294 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
295 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
296 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
297 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
298 // Add vector and float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
299 RMAPI Vector2 Vector2AddValue(Vector2 v, float add) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
300 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
301 Vector2 result = { v.x + add, v.y + add }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
302 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
303 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
304 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
305 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
306 // Subtract two vectors (v1 - v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
307 RMAPI Vector2 Vector2Subtract(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
308 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
309 Vector2 result = { v1.x - v2.x, v1.y - v2.y }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
310 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
311 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
312 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
313 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
314 // Subtract vector by float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
315 RMAPI Vector2 Vector2SubtractValue(Vector2 v, float sub) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
316 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
317 Vector2 result = { v.x - sub, v.y - sub }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
318 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
319 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
320 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
321 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
322 // Calculate vector length |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
323 RMAPI float Vector2Length(Vector2 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
324 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
325 float result = sqrtf((v.x*v.x) + (v.y*v.y)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
326 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
327 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
328 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
329 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
330 // Calculate vector square length |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
331 RMAPI float Vector2LengthSqr(Vector2 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
332 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
333 float result = (v.x*v.x) + (v.y*v.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
334 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
335 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
336 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
337 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
338 // Calculate two vectors dot product |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
339 RMAPI float Vector2DotProduct(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
340 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
341 float result = (v1.x*v2.x + v1.y*v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
342 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
343 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
344 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
345 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
346 // Calculate two vectors cross product |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
347 RMAPI float Vector2CrossProduct(Vector2 v1, Vector2 v2) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
348 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
349 float result = (v1.x*v2.y - v1.y*v2.x); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
350 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
351 return result; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
352 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
353 |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
354 // Calculate distance between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
355 RMAPI float Vector2Distance(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
356 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
357 float result = sqrtf((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
358 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
359 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
360 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
361 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
362 // Calculate square distance between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
363 RMAPI float Vector2DistanceSqr(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
364 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
365 float result = ((v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
366 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
367 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
368 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
369 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
370 // Calculate the signed angle from v1 to v2, relative to the origin (0, 0) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
371 // NOTE: Coordinate system convention: positive X right, positive Y down |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
372 // positive angles appear clockwise, and negative angles appear counterclockwise |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
373 RMAPI float Vector2Angle(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
374 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
375 float result = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
376 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
377 float dot = v1.x*v2.x + v1.y*v2.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
378 float det = v1.x*v2.y - v1.y*v2.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
379 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
380 result = atan2f(det, dot); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
381 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
382 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
383 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
384 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
385 // Calculate angle defined by a two vectors line |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
386 // NOTE: Parameters need to be normalized |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
387 // Current implementation should be aligned with glm::angle |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
388 RMAPI float Vector2LineAngle(Vector2 start, Vector2 end) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
389 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
390 float result = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
391 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
392 // TODO(10/9/2023): Currently angles move clockwise, determine if this is wanted behavior |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
393 result = -atan2f(end.y - start.y, end.x - start.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
394 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
395 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
396 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
397 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
398 // Scale vector (multiply by value) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
399 RMAPI Vector2 Vector2Scale(Vector2 v, float scale) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
400 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
401 Vector2 result = { v.x*scale, v.y*scale }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
402 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
403 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
404 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
405 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
406 // Multiply vector by vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
407 RMAPI Vector2 Vector2Multiply(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
408 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
409 Vector2 result = { v1.x*v2.x, v1.y*v2.y }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
410 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
411 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
412 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
413 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
414 // Negate vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
415 RMAPI Vector2 Vector2Negate(Vector2 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
416 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
417 Vector2 result = { -v.x, -v.y }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
418 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
419 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
420 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
421 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
422 // Divide vector by vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
423 RMAPI Vector2 Vector2Divide(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
424 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
425 Vector2 result = { v1.x/v2.x, v1.y/v2.y }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
426 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
427 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
428 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
429 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
430 // Normalize provided vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
431 RMAPI Vector2 Vector2Normalize(Vector2 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
432 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
433 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
434 float length = sqrtf((v.x*v.x) + (v.y*v.y)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
435 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
436 if (length > 0) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
437 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
438 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
439 result.x = v.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
440 result.y = v.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
441 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
442 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
443 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
444 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
445 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
446 // Transforms a Vector2 by a given Matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
447 RMAPI Vector2 Vector2Transform(Vector2 v, Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
448 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
449 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
450 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
451 float x = v.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
452 float y = v.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
453 float z = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
454 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
455 result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
456 result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
457 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
458 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
459 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
460 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
461 // Calculate linear interpolation between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
462 RMAPI Vector2 Vector2Lerp(Vector2 v1, Vector2 v2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
463 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
464 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
465 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
466 result.x = v1.x + amount*(v2.x - v1.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
467 result.y = v1.y + amount*(v2.y - v1.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
468 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
469 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
470 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
471 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
472 // Calculate reflected vector to normal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
473 RMAPI Vector2 Vector2Reflect(Vector2 v, Vector2 normal) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
474 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
475 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
476 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
477 float dotProduct = (v.x*normal.x + v.y*normal.y); // Dot product |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
478 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
479 result.x = v.x - (2.0f*normal.x)*dotProduct; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
480 result.y = v.y - (2.0f*normal.y)*dotProduct; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
481 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
482 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
483 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
484 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
485 // Get min value for each pair of components |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
486 RMAPI Vector2 Vector2Min(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
487 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
488 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
489 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
490 result.x = fminf(v1.x, v2.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
491 result.y = fminf(v1.y, v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
492 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
493 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
494 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
495 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
496 // Get max value for each pair of components |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
497 RMAPI Vector2 Vector2Max(Vector2 v1, Vector2 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
498 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
499 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
500 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
501 result.x = fmaxf(v1.x, v2.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
502 result.y = fmaxf(v1.y, v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
503 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
504 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
505 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
506 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
507 // Rotate vector by angle |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
508 RMAPI Vector2 Vector2Rotate(Vector2 v, float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
509 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
510 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
511 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
512 float cosres = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
513 float sinres = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
514 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
515 result.x = v.x*cosres - v.y*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
516 result.y = v.x*sinres + v.y*cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
517 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
518 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
519 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
520 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
521 // Move Vector towards target |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
522 RMAPI Vector2 Vector2MoveTowards(Vector2 v, Vector2 target, float maxDistance) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
523 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
524 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
525 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
526 float dx = target.x - v.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
527 float dy = target.y - v.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
528 float value = (dx*dx) + (dy*dy); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
529 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
530 if ((value == 0) || ((maxDistance >= 0) && (value <= maxDistance*maxDistance))) return target; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
531 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
532 float dist = sqrtf(value); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
533 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
534 result.x = v.x + dx/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
535 result.y = v.y + dy/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
536 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
537 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
538 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
539 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
540 // Invert the given vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
541 RMAPI Vector2 Vector2Invert(Vector2 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
542 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
543 Vector2 result = { 1.0f/v.x, 1.0f/v.y }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
544 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
545 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
546 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
547 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
548 // Clamp the components of the vector between |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
549 // min and max values specified by the given vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
550 RMAPI Vector2 Vector2Clamp(Vector2 v, Vector2 min, Vector2 max) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
551 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
552 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
553 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
554 result.x = fminf(max.x, fmaxf(min.x, v.x)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
555 result.y = fminf(max.y, fmaxf(min.y, v.y)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
556 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
557 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
558 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
559 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
560 // Clamp the magnitude of the vector between two min and max values |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
561 RMAPI Vector2 Vector2ClampValue(Vector2 v, float min, float max) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
562 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
563 Vector2 result = v; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
564 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
565 float length = (v.x*v.x) + (v.y*v.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
566 if (length > 0.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
567 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
568 length = sqrtf(length); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
569 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
570 float scale = 1; // By default, 1 as the neutral element |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
571 if (length < min) scale = min/length; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
572 else if (length > max) scale = max/length; |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
573 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
574 result.x = v.x*scale; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
575 result.y = v.y*scale; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
576 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
577 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
578 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
579 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
580 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
581 // Check whether two given vectors are almost equal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
582 RMAPI int Vector2Equals(Vector2 p, Vector2 q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
583 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
584 #if !defined(EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
585 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
586 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
587 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
588 int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
589 ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
590 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
591 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
592 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
593 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
594 // Compute the direction of a refracted ray |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
595 // v: normalized direction of the incoming ray |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
596 // n: normalized normal vector of the interface of two optical media |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
597 // r: ratio of the refractive index of the medium from where the ray comes |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
598 // to the refractive index of the medium on the other side of the surface |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
599 RMAPI Vector2 Vector2Refract(Vector2 v, Vector2 n, float r) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
600 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
601 Vector2 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
602 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
603 float dot = v.x*n.x + v.y*n.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
604 float d = 1.0f - r*r*(1.0f - dot*dot); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
605 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
606 if (d >= 0.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
607 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
608 d = sqrtf(d); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
609 v.x = r*v.x - (r*dot + d)*n.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
610 v.y = r*v.y - (r*dot + d)*n.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
611 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
612 result = v; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
613 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
614 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
615 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
616 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
617 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
618 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
619 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
620 // Module Functions Definition - Vector3 math |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
621 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
622 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
623 // Vector with components value 0.0f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
624 RMAPI Vector3 Vector3Zero(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
625 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
626 Vector3 result = { 0.0f, 0.0f, 0.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
627 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
628 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
629 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
630 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
631 // Vector with components value 1.0f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
632 RMAPI Vector3 Vector3One(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
633 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
634 Vector3 result = { 1.0f, 1.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
635 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
636 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
637 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
638 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
639 // Add two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
640 RMAPI Vector3 Vector3Add(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
641 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
642 Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
643 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
644 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
645 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
646 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
647 // Add vector and float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
648 RMAPI Vector3 Vector3AddValue(Vector3 v, float add) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
649 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
650 Vector3 result = { v.x + add, v.y + add, v.z + add }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
651 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
652 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
653 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
654 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
655 // Subtract two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
656 RMAPI Vector3 Vector3Subtract(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
657 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
658 Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
659 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
660 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
661 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
662 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
663 // Subtract vector by float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
664 RMAPI Vector3 Vector3SubtractValue(Vector3 v, float sub) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
665 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
666 Vector3 result = { v.x - sub, v.y - sub, v.z - sub }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
667 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
668 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
669 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
670 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
671 // Multiply vector by scalar |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
672 RMAPI Vector3 Vector3Scale(Vector3 v, float scalar) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
673 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
674 Vector3 result = { v.x*scalar, v.y*scalar, v.z*scalar }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
675 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
676 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
677 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
678 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
679 // Multiply vector by vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
680 RMAPI Vector3 Vector3Multiply(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
681 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
682 Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
683 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
684 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
685 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
686 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
687 // Calculate two vectors cross product |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
688 RMAPI Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
689 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
690 Vector3 result = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
691 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
692 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
693 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
694 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
695 // Calculate one vector perpendicular vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
696 RMAPI Vector3 Vector3Perpendicular(Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
697 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
698 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
699 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
700 float min = fabsf(v.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
701 Vector3 cardinalAxis = {1.0f, 0.0f, 0.0f}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
702 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
703 if (fabsf(v.y) < min) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
704 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
705 min = fabsf(v.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
706 Vector3 tmp = {0.0f, 1.0f, 0.0f}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
707 cardinalAxis = tmp; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
708 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
709 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
710 if (fabsf(v.z) < min) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
711 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
712 Vector3 tmp = {0.0f, 0.0f, 1.0f}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
713 cardinalAxis = tmp; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
714 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
715 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
716 // Cross product between vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
717 result.x = v.y*cardinalAxis.z - v.z*cardinalAxis.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
718 result.y = v.z*cardinalAxis.x - v.x*cardinalAxis.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
719 result.z = v.x*cardinalAxis.y - v.y*cardinalAxis.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
720 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
721 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
722 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
723 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
724 // Calculate vector length |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
725 RMAPI float Vector3Length(const Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
726 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
727 float result = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
728 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
729 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
730 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
731 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
732 // Calculate vector square length |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
733 RMAPI float Vector3LengthSqr(const Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
734 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
735 float result = v.x*v.x + v.y*v.y + v.z*v.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
736 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
737 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
738 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
739 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
740 // Calculate two vectors dot product |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
741 RMAPI float Vector3DotProduct(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
742 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
743 float result = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
744 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
745 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
746 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
747 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
748 // Calculate distance between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
749 RMAPI float Vector3Distance(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
750 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
751 float result = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
752 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
753 float dx = v2.x - v1.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
754 float dy = v2.y - v1.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
755 float dz = v2.z - v1.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
756 result = sqrtf(dx*dx + dy*dy + dz*dz); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
757 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
758 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
759 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
760 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
761 // Calculate square distance between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
762 RMAPI float Vector3DistanceSqr(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
763 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
764 float result = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
765 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
766 float dx = v2.x - v1.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
767 float dy = v2.y - v1.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
768 float dz = v2.z - v1.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
769 result = dx*dx + dy*dy + dz*dz; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
770 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
771 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
772 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
773 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
774 // Calculate angle between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
775 RMAPI float Vector3Angle(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
776 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
777 float result = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
778 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
779 Vector3 cross = { v1.y*v2.z - v1.z*v2.y, v1.z*v2.x - v1.x*v2.z, v1.x*v2.y - v1.y*v2.x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
780 float len = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
781 float dot = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
782 result = atan2f(len, dot); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
783 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
784 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
785 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
786 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
787 // Negate provided vector (invert direction) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
788 RMAPI Vector3 Vector3Negate(Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
789 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
790 Vector3 result = { -v.x, -v.y, -v.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
791 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
792 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
793 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
794 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
795 // Divide vector by vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
796 RMAPI Vector3 Vector3Divide(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
797 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
798 Vector3 result = { v1.x/v2.x, v1.y/v2.y, v1.z/v2.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
799 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
800 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
801 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
802 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
803 // Normalize provided vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
804 RMAPI Vector3 Vector3Normalize(Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
805 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
806 Vector3 result = v; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
807 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
808 float length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
809 if (length != 0.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
810 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
811 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
812 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
813 result.x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
814 result.y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
815 result.z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
816 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
817 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
818 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
819 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
820 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
821 //Calculate the projection of the vector v1 on to v2 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
822 RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
823 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
824 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
825 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
826 float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
827 float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
828 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
829 float mag = v1dv2/v2dv2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
830 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
831 result.x = v2.x*mag; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
832 result.y = v2.y*mag; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
833 result.z = v2.z*mag; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
834 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
835 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
836 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
837 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
838 //Calculate the rejection of the vector v1 on to v2 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
839 RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
840 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
841 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
842 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
843 float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
844 float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
845 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
846 float mag = v1dv2/v2dv2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
847 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
848 result.x = v1.x - (v2.x*mag); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
849 result.y = v1.y - (v2.y*mag); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
850 result.z = v1.z - (v2.z*mag); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
851 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
852 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
853 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
854 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
855 // Orthonormalize provided vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
856 // Makes vectors normalized and orthogonal to each other |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
857 // Gram-Schmidt function implementation |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
858 RMAPI void Vector3OrthoNormalize(Vector3 *v1, Vector3 *v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
859 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
860 float length = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
861 float ilength = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
862 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
863 // Vector3Normalize(*v1); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
864 Vector3 v = *v1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
865 length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
866 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
867 ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
868 v1->x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
869 v1->y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
870 v1->z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
871 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
872 // Vector3CrossProduct(*v1, *v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
873 Vector3 vn1 = { v1->y*v2->z - v1->z*v2->y, v1->z*v2->x - v1->x*v2->z, v1->x*v2->y - v1->y*v2->x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
874 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
875 // Vector3Normalize(vn1); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
876 v = vn1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
877 length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
878 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
879 ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
880 vn1.x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
881 vn1.y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
882 vn1.z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
883 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
884 // Vector3CrossProduct(vn1, *v1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
885 Vector3 vn2 = { vn1.y*v1->z - vn1.z*v1->y, vn1.z*v1->x - vn1.x*v1->z, vn1.x*v1->y - vn1.y*v1->x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
886 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
887 *v2 = vn2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
888 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
889 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
890 // Transforms a Vector3 by a given Matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
891 RMAPI Vector3 Vector3Transform(Vector3 v, Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
892 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
893 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
894 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
895 float x = v.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
896 float y = v.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
897 float z = v.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
898 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
899 result.x = mat.m0*x + mat.m4*y + mat.m8*z + mat.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
900 result.y = mat.m1*x + mat.m5*y + mat.m9*z + mat.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
901 result.z = mat.m2*x + mat.m6*y + mat.m10*z + mat.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
902 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
903 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
904 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
905 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
906 // Transform a vector by quaternion rotation |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
907 RMAPI Vector3 Vector3RotateByQuaternion(Vector3 v, Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
908 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
909 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
910 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
911 result.x = v.x*(q.x*q.x + q.w*q.w - q.y*q.y - q.z*q.z) + v.y*(2*q.x*q.y - 2*q.w*q.z) + v.z*(2*q.x*q.z + 2*q.w*q.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
912 result.y = v.x*(2*q.w*q.z + 2*q.x*q.y) + v.y*(q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z) + v.z*(-2*q.w*q.x + 2*q.y*q.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
913 result.z = v.x*(-2*q.w*q.y + 2*q.x*q.z) + v.y*(2*q.w*q.x + 2*q.y*q.z)+ v.z*(q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
914 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
915 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
916 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
917 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
918 // Rotates a vector around an axis |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
919 RMAPI Vector3 Vector3RotateByAxisAngle(Vector3 v, Vector3 axis, float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
920 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
921 // Using Euler-Rodrigues Formula |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
922 // Ref.: https://en.wikipedia.org/w/index.php?title=Euler%E2%80%93Rodrigues_formula |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
923 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
924 Vector3 result = v; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
925 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
926 // Vector3Normalize(axis); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
927 float length = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
928 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
929 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
930 axis.x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
931 axis.y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
932 axis.z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
933 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
934 angle /= 2.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
935 float a = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
936 float b = axis.x*a; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
937 float c = axis.y*a; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
938 float d = axis.z*a; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
939 a = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
940 Vector3 w = { b, c, d }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
941 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
942 // Vector3CrossProduct(w, v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
943 Vector3 wv = { w.y*v.z - w.z*v.y, w.z*v.x - w.x*v.z, w.x*v.y - w.y*v.x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
944 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
945 // Vector3CrossProduct(w, wv) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
946 Vector3 wwv = { w.y*wv.z - w.z*wv.y, w.z*wv.x - w.x*wv.z, w.x*wv.y - w.y*wv.x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
947 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
948 // Vector3Scale(wv, 2*a) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
949 a *= 2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
950 wv.x *= a; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
951 wv.y *= a; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
952 wv.z *= a; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
953 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
954 // Vector3Scale(wwv, 2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
955 wwv.x *= 2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
956 wwv.y *= 2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
957 wwv.z *= 2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
958 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
959 result.x += wv.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
960 result.y += wv.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
961 result.z += wv.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
962 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
963 result.x += wwv.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
964 result.y += wwv.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
965 result.z += wwv.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
966 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
967 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
968 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
969 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
970 // Move Vector towards target |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
971 RMAPI Vector3 Vector3MoveTowards(Vector3 v, Vector3 target, float maxDistance) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
972 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
973 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
974 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
975 float dx = target.x - v.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
976 float dy = target.y - v.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
977 float dz = target.z - v.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
978 float value = (dx*dx) + (dy*dy) + (dz*dz); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
979 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
980 if ((value == 0) || ((maxDistance >= 0) && (value <= maxDistance*maxDistance))) return target; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
981 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
982 float dist = sqrtf(value); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
983 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
984 result.x = v.x + dx/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
985 result.y = v.y + dy/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
986 result.z = v.z + dz/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
987 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
988 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
989 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
990 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
991 // Calculate linear interpolation between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
992 RMAPI Vector3 Vector3Lerp(Vector3 v1, Vector3 v2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
993 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
994 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
995 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
996 result.x = v1.x + amount*(v2.x - v1.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
997 result.y = v1.y + amount*(v2.y - v1.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
998 result.z = v1.z + amount*(v2.z - v1.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
999 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1000 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1001 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1002 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1003 // Calculate cubic hermite interpolation between two vectors and their tangents |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1004 // as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1005 RMAPI Vector3 Vector3CubicHermite(Vector3 v1, Vector3 tangent1, Vector3 v2, Vector3 tangent2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1006 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1007 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1008 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1009 float amountPow2 = amount*amount; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1010 float amountPow3 = amount*amount*amount; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1011 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1012 result.x = (2*amountPow3 - 3*amountPow2 + 1)*v1.x + (amountPow3 - 2*amountPow2 + amount)*tangent1.x + (-2*amountPow3 + 3*amountPow2)*v2.x + (amountPow3 - amountPow2)*tangent2.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1013 result.y = (2*amountPow3 - 3*amountPow2 + 1)*v1.y + (amountPow3 - 2*amountPow2 + amount)*tangent1.y + (-2*amountPow3 + 3*amountPow2)*v2.y + (amountPow3 - amountPow2)*tangent2.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1014 result.z = (2*amountPow3 - 3*amountPow2 + 1)*v1.z + (amountPow3 - 2*amountPow2 + amount)*tangent1.z + (-2*amountPow3 + 3*amountPow2)*v2.z + (amountPow3 - amountPow2)*tangent2.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1015 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1016 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1017 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1018 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1019 // Calculate reflected vector to normal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1020 RMAPI Vector3 Vector3Reflect(Vector3 v, Vector3 normal) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1021 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1022 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1023 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1024 // I is the original vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1025 // N is the normal of the incident plane |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1026 // R = I - (2*N*(DotProduct[I, N])) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1027 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1028 float dotProduct = (v.x*normal.x + v.y*normal.y + v.z*normal.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1029 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1030 result.x = v.x - (2.0f*normal.x)*dotProduct; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1031 result.y = v.y - (2.0f*normal.y)*dotProduct; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1032 result.z = v.z - (2.0f*normal.z)*dotProduct; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1033 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1034 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1035 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1036 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1037 // Get min value for each pair of components |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1038 RMAPI Vector3 Vector3Min(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1039 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1040 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1041 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1042 result.x = fminf(v1.x, v2.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1043 result.y = fminf(v1.y, v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1044 result.z = fminf(v1.z, v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1045 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1046 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1047 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1048 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1049 // Get max value for each pair of components |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1050 RMAPI Vector3 Vector3Max(Vector3 v1, Vector3 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1051 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1052 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1053 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1054 result.x = fmaxf(v1.x, v2.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1055 result.y = fmaxf(v1.y, v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1056 result.z = fmaxf(v1.z, v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1057 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1058 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1059 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1060 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1061 // Compute barycenter coordinates (u, v, w) for point p with respect to triangle (a, b, c) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1062 // NOTE: Assumes P is on the plane of the triangle |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1063 RMAPI Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1064 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1065 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1066 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1067 Vector3 v0 = { b.x - a.x, b.y - a.y, b.z - a.z }; // Vector3Subtract(b, a) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1068 Vector3 v1 = { c.x - a.x, c.y - a.y, c.z - a.z }; // Vector3Subtract(c, a) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1069 Vector3 v2 = { p.x - a.x, p.y - a.y, p.z - a.z }; // Vector3Subtract(p, a) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1070 float d00 = (v0.x*v0.x + v0.y*v0.y + v0.z*v0.z); // Vector3DotProduct(v0, v0) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1071 float d01 = (v0.x*v1.x + v0.y*v1.y + v0.z*v1.z); // Vector3DotProduct(v0, v1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1072 float d11 = (v1.x*v1.x + v1.y*v1.y + v1.z*v1.z); // Vector3DotProduct(v1, v1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1073 float d20 = (v2.x*v0.x + v2.y*v0.y + v2.z*v0.z); // Vector3DotProduct(v2, v0) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1074 float d21 = (v2.x*v1.x + v2.y*v1.y + v2.z*v1.z); // Vector3DotProduct(v2, v1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1075 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1076 float denom = d00*d11 - d01*d01; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1077 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1078 result.y = (d11*d20 - d01*d21)/denom; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1079 result.z = (d00*d21 - d01*d20)/denom; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1080 result.x = 1.0f - (result.z + result.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1081 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1082 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1083 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1084 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1085 // Projects a Vector3 from screen space into object space |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1086 // NOTE: Self-contained function, no other raymath functions are called |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1087 RMAPI Vector3 Vector3Unproject(Vector3 source, Matrix projection, Matrix view) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1088 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1089 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1090 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1091 // Calculate unprojected matrix (multiply view matrix by projection matrix) and invert it |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1092 Matrix matViewProj = { // MatrixMultiply(view, projection); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1093 view.m0*projection.m0 + view.m1*projection.m4 + view.m2*projection.m8 + view.m3*projection.m12, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1094 view.m0*projection.m1 + view.m1*projection.m5 + view.m2*projection.m9 + view.m3*projection.m13, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1095 view.m0*projection.m2 + view.m1*projection.m6 + view.m2*projection.m10 + view.m3*projection.m14, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1096 view.m0*projection.m3 + view.m1*projection.m7 + view.m2*projection.m11 + view.m3*projection.m15, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1097 view.m4*projection.m0 + view.m5*projection.m4 + view.m6*projection.m8 + view.m7*projection.m12, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1098 view.m4*projection.m1 + view.m5*projection.m5 + view.m6*projection.m9 + view.m7*projection.m13, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1099 view.m4*projection.m2 + view.m5*projection.m6 + view.m6*projection.m10 + view.m7*projection.m14, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1100 view.m4*projection.m3 + view.m5*projection.m7 + view.m6*projection.m11 + view.m7*projection.m15, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1101 view.m8*projection.m0 + view.m9*projection.m4 + view.m10*projection.m8 + view.m11*projection.m12, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1102 view.m8*projection.m1 + view.m9*projection.m5 + view.m10*projection.m9 + view.m11*projection.m13, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1103 view.m8*projection.m2 + view.m9*projection.m6 + view.m10*projection.m10 + view.m11*projection.m14, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1104 view.m8*projection.m3 + view.m9*projection.m7 + view.m10*projection.m11 + view.m11*projection.m15, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1105 view.m12*projection.m0 + view.m13*projection.m4 + view.m14*projection.m8 + view.m15*projection.m12, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1106 view.m12*projection.m1 + view.m13*projection.m5 + view.m14*projection.m9 + view.m15*projection.m13, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1107 view.m12*projection.m2 + view.m13*projection.m6 + view.m14*projection.m10 + view.m15*projection.m14, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1108 view.m12*projection.m3 + view.m13*projection.m7 + view.m14*projection.m11 + view.m15*projection.m15 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1109 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1110 // Calculate inverted matrix -> MatrixInvert(matViewProj); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1111 // Cache the matrix values (speed optimization) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1112 float a00 = matViewProj.m0, a01 = matViewProj.m1, a02 = matViewProj.m2, a03 = matViewProj.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1113 float a10 = matViewProj.m4, a11 = matViewProj.m5, a12 = matViewProj.m6, a13 = matViewProj.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1114 float a20 = matViewProj.m8, a21 = matViewProj.m9, a22 = matViewProj.m10, a23 = matViewProj.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1115 float a30 = matViewProj.m12, a31 = matViewProj.m13, a32 = matViewProj.m14, a33 = matViewProj.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1116 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1117 float b00 = a00*a11 - a01*a10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1118 float b01 = a00*a12 - a02*a10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1119 float b02 = a00*a13 - a03*a10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1120 float b03 = a01*a12 - a02*a11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1121 float b04 = a01*a13 - a03*a11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1122 float b05 = a02*a13 - a03*a12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1123 float b06 = a20*a31 - a21*a30; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1124 float b07 = a20*a32 - a22*a30; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1125 float b08 = a20*a33 - a23*a30; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1126 float b09 = a21*a32 - a22*a31; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1127 float b10 = a21*a33 - a23*a31; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1128 float b11 = a22*a33 - a23*a32; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1129 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1130 // Calculate the invert determinant (inlined to avoid double-caching) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1131 float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1132 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1133 Matrix matViewProjInv = { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1134 (a11*b11 - a12*b10 + a13*b09)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1135 (-a01*b11 + a02*b10 - a03*b09)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1136 (a31*b05 - a32*b04 + a33*b03)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1137 (-a21*b05 + a22*b04 - a23*b03)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1138 (-a10*b11 + a12*b08 - a13*b07)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1139 (a00*b11 - a02*b08 + a03*b07)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1140 (-a30*b05 + a32*b02 - a33*b01)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1141 (a20*b05 - a22*b02 + a23*b01)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1142 (a10*b10 - a11*b08 + a13*b06)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1143 (-a00*b10 + a01*b08 - a03*b06)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1144 (a30*b04 - a31*b02 + a33*b00)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1145 (-a20*b04 + a21*b02 - a23*b00)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1146 (-a10*b09 + a11*b07 - a12*b06)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1147 (a00*b09 - a01*b07 + a02*b06)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1148 (-a30*b03 + a31*b01 - a32*b00)*invDet, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1149 (a20*b03 - a21*b01 + a22*b00)*invDet }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1150 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1151 // Create quaternion from source point |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1152 Quaternion quat = { source.x, source.y, source.z, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1153 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1154 // Multiply quat point by unprojected matrix |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1155 Quaternion qtransformed = { // QuaternionTransform(quat, matViewProjInv) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1156 matViewProjInv.m0*quat.x + matViewProjInv.m4*quat.y + matViewProjInv.m8*quat.z + matViewProjInv.m12*quat.w, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1157 matViewProjInv.m1*quat.x + matViewProjInv.m5*quat.y + matViewProjInv.m9*quat.z + matViewProjInv.m13*quat.w, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1158 matViewProjInv.m2*quat.x + matViewProjInv.m6*quat.y + matViewProjInv.m10*quat.z + matViewProjInv.m14*quat.w, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1159 matViewProjInv.m3*quat.x + matViewProjInv.m7*quat.y + matViewProjInv.m11*quat.z + matViewProjInv.m15*quat.w }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1160 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1161 // Normalized world points in vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1162 result.x = qtransformed.x/qtransformed.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1163 result.y = qtransformed.y/qtransformed.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1164 result.z = qtransformed.z/qtransformed.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1165 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1166 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1167 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1168 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1169 // Get Vector3 as float array |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1170 RMAPI float3 Vector3ToFloatV(Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1171 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1172 float3 buffer = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1173 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1174 buffer.v[0] = v.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1175 buffer.v[1] = v.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1176 buffer.v[2] = v.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1177 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1178 return buffer; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1179 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1180 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1181 // Invert the given vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1182 RMAPI Vector3 Vector3Invert(Vector3 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1183 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1184 Vector3 result = { 1.0f/v.x, 1.0f/v.y, 1.0f/v.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1185 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1186 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1187 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1188 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1189 // Clamp the components of the vector between |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1190 // min and max values specified by the given vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1191 RMAPI Vector3 Vector3Clamp(Vector3 v, Vector3 min, Vector3 max) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1192 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1193 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1194 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1195 result.x = fminf(max.x, fmaxf(min.x, v.x)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1196 result.y = fminf(max.y, fmaxf(min.y, v.y)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1197 result.z = fminf(max.z, fmaxf(min.z, v.z)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1198 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1199 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1200 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1201 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1202 // Clamp the magnitude of the vector between two values |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1203 RMAPI Vector3 Vector3ClampValue(Vector3 v, float min, float max) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1204 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1205 Vector3 result = v; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1206 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1207 float length = (v.x*v.x) + (v.y*v.y) + (v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1208 if (length > 0.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1209 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1210 length = sqrtf(length); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1211 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1212 float scale = 1; // By default, 1 as the neutral element |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1213 if (length < min) scale = min/length; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1214 else if (length > max) scale = max/length; |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1215 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1216 result.x = v.x*scale; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1217 result.y = v.y*scale; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1218 result.z = v.z*scale; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1219 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1220 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1221 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1222 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1223 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1224 // Check whether two given vectors are almost equal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1225 RMAPI int Vector3Equals(Vector3 p, Vector3 q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1226 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1227 #if !defined(EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1228 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1229 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1230 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1231 int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1232 ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1233 ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1234 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1235 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1236 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1237 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1238 // Compute the direction of a refracted ray |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1239 // v: normalized direction of the incoming ray |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1240 // n: normalized normal vector of the interface of two optical media |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1241 // r: ratio of the refractive index of the medium from where the ray comes |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1242 // to the refractive index of the medium on the other side of the surface |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1243 RMAPI Vector3 Vector3Refract(Vector3 v, Vector3 n, float r) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1244 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1245 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1246 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1247 float dot = v.x*n.x + v.y*n.y + v.z*n.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1248 float d = 1.0f - r*r*(1.0f - dot*dot); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1249 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1250 if (d >= 0.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1251 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1252 d = sqrtf(d); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1253 v.x = r*v.x - (r*dot + d)*n.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1254 v.y = r*v.y - (r*dot + d)*n.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1255 v.z = r*v.z - (r*dot + d)*n.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1256 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1257 result = v; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1258 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1259 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1260 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1261 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1262 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1263 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1264 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1265 // Module Functions Definition - Vector4 math |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1266 //---------------------------------------------------------------------------------- |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1267 // Get vector zero |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1268 RMAPI Vector4 Vector4Zero(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1269 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1270 Vector4 result = { 0.0f, 0.0f, 0.0f, 0.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1271 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1272 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1273 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1274 // Get vector one |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1275 RMAPI Vector4 Vector4One(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1276 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1277 Vector4 result = { 1.0f, 1.0f, 1.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1278 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1279 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1280 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1281 // Add two vectors |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1282 RMAPI Vector4 Vector4Add(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1283 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1284 Vector4 result = { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1285 v1.x + v2.x, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1286 v1.y + v2.y, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1287 v1.z + v2.z, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1288 v1.w + v2.w |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1289 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1290 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1291 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1292 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1293 // Add value to vector components |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1294 RMAPI Vector4 Vector4AddValue(Vector4 v, float add) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1295 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1296 Vector4 result = { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1297 v.x + add, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1298 v.y + add, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1299 v.z + add, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1300 v.w + add |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1301 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1302 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1303 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1304 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1305 // Substract vectors |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1306 RMAPI Vector4 Vector4Subtract(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1307 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1308 Vector4 result = { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1309 v1.x - v2.x, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1310 v1.y - v2.y, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1311 v1.z - v2.z, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1312 v1.w - v2.w |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1313 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1314 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1315 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1316 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1317 // Substract value from vector components |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1318 RMAPI Vector4 Vector4SubtractValue(Vector4 v, float add) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1319 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1320 Vector4 result = { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1321 v.x - add, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1322 v.y - add, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1323 v.z - add, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1324 v.w - add |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1325 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1326 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1327 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1328 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1329 // Vector length |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1330 RMAPI float Vector4Length(Vector4 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1331 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1332 float result = sqrtf((v.x*v.x) + (v.y*v.y) + (v.z*v.z) + (v.w*v.w)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1333 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1334 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1335 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1336 // Vector square length |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1337 RMAPI float Vector4LengthSqr(Vector4 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1338 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1339 float result = (v.x*v.x) + (v.y*v.y) + (v.z*v.z) + (v.w*v.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1340 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1341 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1342 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1343 // Vectors dot product |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1344 RMAPI float Vector4DotProduct(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1345 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1346 float result = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z + v1.w*v2.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1347 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1348 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1349 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1350 // Calculate distance between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1351 RMAPI float Vector4Distance(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1352 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1353 float result = sqrtf( |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1354 (v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y) + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1355 (v1.z - v2.z)*(v1.z - v2.z) + (v1.w - v2.w)*(v1.w - v2.w)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1356 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1357 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1358 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1359 // Calculate square distance between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1360 RMAPI float Vector4DistanceSqr(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1361 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1362 float result = |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1363 (v1.x - v2.x)*(v1.x - v2.x) + (v1.y - v2.y)*(v1.y - v2.y) + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1364 (v1.z - v2.z)*(v1.z - v2.z) + (v1.w - v2.w)*(v1.w - v2.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1365 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1366 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1367 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1368 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1369 // Scale vector components by value (multiply) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1370 RMAPI Vector4 Vector4Scale(Vector4 v, float scale) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1371 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1372 Vector4 result = { v.x*scale, v.y*scale, v.z*scale, v.w*scale }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1373 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1374 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1375 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1376 // Multiply vector by vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1377 RMAPI Vector4 Vector4Multiply(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1378 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1379 Vector4 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z, v1.w*v2.w }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1380 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1381 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1382 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1383 // Negate vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1384 RMAPI Vector4 Vector4Negate(Vector4 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1385 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1386 Vector4 result = { -v.x, -v.y, -v.z, -v.w }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1387 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1388 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1389 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1390 // Divide vector by vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1391 RMAPI Vector4 Vector4Divide(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1392 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1393 Vector4 result = { v1.x/v2.x, v1.y/v2.y, v1.z/v2.z, v1.w/v2.w }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1394 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1395 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1396 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1397 // Normalize provided vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1398 RMAPI Vector4 Vector4Normalize(Vector4 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1399 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1400 Vector4 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1401 float length = sqrtf((v.x*v.x) + (v.y*v.y) + (v.z*v.z) + (v.w*v.w)); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1402 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1403 if (length > 0) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1404 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1405 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1406 result.x = v.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1407 result.y = v.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1408 result.z = v.z*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1409 result.w = v.w*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1410 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1411 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1412 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1413 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1414 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1415 // Get min value for each pair of components |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1416 RMAPI Vector4 Vector4Min(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1417 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1418 Vector4 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1419 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1420 result.x = fminf(v1.x, v2.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1421 result.y = fminf(v1.y, v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1422 result.z = fminf(v1.z, v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1423 result.w = fminf(v1.w, v2.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1424 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1425 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1426 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1427 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1428 // Get max value for each pair of components |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1429 RMAPI Vector4 Vector4Max(Vector4 v1, Vector4 v2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1430 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1431 Vector4 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1432 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1433 result.x = fmaxf(v1.x, v2.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1434 result.y = fmaxf(v1.y, v2.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1435 result.z = fmaxf(v1.z, v2.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1436 result.w = fmaxf(v1.w, v2.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1437 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1438 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1439 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1440 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1441 // Calculate linear interpolation between two vectors |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1442 RMAPI Vector4 Vector4Lerp(Vector4 v1, Vector4 v2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1443 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1444 Vector4 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1445 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1446 result.x = v1.x + amount*(v2.x - v1.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1447 result.y = v1.y + amount*(v2.y - v1.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1448 result.z = v1.z + amount*(v2.z - v1.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1449 result.w = v1.w + amount*(v2.w - v1.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1450 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1451 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1452 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1453 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1454 // Move Vector towards target |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1455 RMAPI Vector4 Vector4MoveTowards(Vector4 v, Vector4 target, float maxDistance) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1456 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1457 Vector4 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1458 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1459 float dx = target.x - v.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1460 float dy = target.y - v.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1461 float dz = target.z - v.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1462 float dw = target.w - v.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1463 float value = (dx*dx) + (dy*dy) + (dz*dz) + (dw*dw); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1464 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1465 if ((value == 0) || ((maxDistance >= 0) && (value <= maxDistance*maxDistance))) return target; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1466 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1467 float dist = sqrtf(value); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1468 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1469 result.x = v.x + dx/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1470 result.y = v.y + dy/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1471 result.z = v.z + dz/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1472 result.w = v.w + dw/dist*maxDistance; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1473 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1474 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1475 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1476 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1477 // Invert the given vector |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1478 RMAPI Vector4 Vector4Invert(Vector4 v) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1479 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1480 Vector4 result = { 1.0f/v.x, 1.0f/v.y, 1.0f/v.z, 1.0f/v.w }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1481 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1482 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1483 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1484 // Check whether two given vectors are almost equal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1485 RMAPI int Vector4Equals(Vector4 p, Vector4 q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1486 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1487 #if !defined(EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1488 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1489 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1490 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1491 int result = ((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1492 ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1493 ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1494 ((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w))))); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1495 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1496 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1497 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1498 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1499 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1500 // Module Functions Definition - Matrix math |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1501 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1502 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1503 // Compute matrix determinant |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1504 RMAPI float MatrixDeterminant(Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1505 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1506 float result = 0.0f; |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1507 /* |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1508 // Cache the matrix values (speed optimization) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1509 float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1510 float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1511 float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1512 float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1513 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1514 // NOTE: It takes 72 multiplication to calculate 4x4 matrix determinant |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1515 result = a30*a21*a12*a03 - a20*a31*a12*a03 - a30*a11*a22*a03 + a10*a31*a22*a03 + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1516 a20*a11*a32*a03 - a10*a21*a32*a03 - a30*a21*a02*a13 + a20*a31*a02*a13 + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1517 a30*a01*a22*a13 - a00*a31*a22*a13 - a20*a01*a32*a13 + a00*a21*a32*a13 + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1518 a30*a11*a02*a23 - a10*a31*a02*a23 - a30*a01*a12*a23 + a00*a31*a12*a23 + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1519 a10*a01*a32*a23 - a00*a11*a32*a23 - a20*a11*a02*a33 + a10*a21*a02*a33 + |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1520 a20*a01*a12*a33 - a00*a21*a12*a33 - a10*a01*a22*a33 + a00*a11*a22*a33; |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1521 */ |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1522 // Using Laplace expansion (https://en.wikipedia.org/wiki/Laplace_expansion), |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1523 // previous operation can be simplified to 40 multiplications, decreasing matrix |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1524 // size from 4x4 to 2x2 using minors |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1525 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1526 // Cache the matrix values (speed optimization) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1527 float m0 = mat.m0, m1 = mat.m1, m2 = mat.m2, m3 = mat.m3; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1528 float m4 = mat.m4, m5 = mat.m5, m6 = mat.m6, m7 = mat.m7; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1529 float m8 = mat.m8, m9 = mat.m9, m10 = mat.m10, m11 = mat.m11; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1530 float m12 = mat.m12, m13 = mat.m13, m14 = mat.m14, m15 = mat.m15; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1531 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1532 result = (m0*((m5*(m10*m15 - m11*m14) - m9*(m6*m15 - m7*m14) + m13*(m6*m11 - m7*m10))) - |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1533 m4*((m1*(m10*m15 - m11*m14) - m9*(m2*m15 - m3*m14) + m13*(m2*m11 - m3*m10))) + |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1534 m8*((m1*(m6*m15 - m7*m14) - m5*(m2*m15 - m3*m14) + m13*(m2*m7 - m3*m6))) - |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1535 m12*((m1*(m6*m11 - m7*m10) - m5*(m2*m11 - m3*m10) + m9*(m2*m7 - m3*m6)))); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1536 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1537 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1538 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1539 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1540 // Get the trace of the matrix (sum of the values along the diagonal) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1541 RMAPI float MatrixTrace(Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1542 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1543 float result = (mat.m0 + mat.m5 + mat.m10 + mat.m15); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1544 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1545 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1546 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1547 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1548 // Transposes provided matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1549 RMAPI Matrix MatrixTranspose(Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1550 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1551 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1552 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1553 result.m0 = mat.m0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1554 result.m1 = mat.m4; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1555 result.m2 = mat.m8; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1556 result.m3 = mat.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1557 result.m4 = mat.m1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1558 result.m5 = mat.m5; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1559 result.m6 = mat.m9; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1560 result.m7 = mat.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1561 result.m8 = mat.m2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1562 result.m9 = mat.m6; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1563 result.m10 = mat.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1564 result.m11 = mat.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1565 result.m12 = mat.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1566 result.m13 = mat.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1567 result.m14 = mat.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1568 result.m15 = mat.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1569 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1570 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1571 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1572 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1573 // Invert provided matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1574 RMAPI Matrix MatrixInvert(Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1575 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1576 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1577 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1578 // Cache the matrix values (speed optimization) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1579 float a00 = mat.m0, a01 = mat.m1, a02 = mat.m2, a03 = mat.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1580 float a10 = mat.m4, a11 = mat.m5, a12 = mat.m6, a13 = mat.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1581 float a20 = mat.m8, a21 = mat.m9, a22 = mat.m10, a23 = mat.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1582 float a30 = mat.m12, a31 = mat.m13, a32 = mat.m14, a33 = mat.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1583 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1584 float b00 = a00*a11 - a01*a10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1585 float b01 = a00*a12 - a02*a10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1586 float b02 = a00*a13 - a03*a10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1587 float b03 = a01*a12 - a02*a11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1588 float b04 = a01*a13 - a03*a11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1589 float b05 = a02*a13 - a03*a12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1590 float b06 = a20*a31 - a21*a30; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1591 float b07 = a20*a32 - a22*a30; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1592 float b08 = a20*a33 - a23*a30; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1593 float b09 = a21*a32 - a22*a31; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1594 float b10 = a21*a33 - a23*a31; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1595 float b11 = a22*a33 - a23*a32; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1596 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1597 // Calculate the invert determinant (inlined to avoid double-caching) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1598 float invDet = 1.0f/(b00*b11 - b01*b10 + b02*b09 + b03*b08 - b04*b07 + b05*b06); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1599 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1600 result.m0 = (a11*b11 - a12*b10 + a13*b09)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1601 result.m1 = (-a01*b11 + a02*b10 - a03*b09)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1602 result.m2 = (a31*b05 - a32*b04 + a33*b03)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1603 result.m3 = (-a21*b05 + a22*b04 - a23*b03)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1604 result.m4 = (-a10*b11 + a12*b08 - a13*b07)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1605 result.m5 = (a00*b11 - a02*b08 + a03*b07)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1606 result.m6 = (-a30*b05 + a32*b02 - a33*b01)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1607 result.m7 = (a20*b05 - a22*b02 + a23*b01)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1608 result.m8 = (a10*b10 - a11*b08 + a13*b06)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1609 result.m9 = (-a00*b10 + a01*b08 - a03*b06)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1610 result.m10 = (a30*b04 - a31*b02 + a33*b00)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1611 result.m11 = (-a20*b04 + a21*b02 - a23*b00)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1612 result.m12 = (-a10*b09 + a11*b07 - a12*b06)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1613 result.m13 = (a00*b09 - a01*b07 + a02*b06)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1614 result.m14 = (-a30*b03 + a31*b01 - a32*b00)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1615 result.m15 = (a20*b03 - a21*b01 + a22*b00)*invDet; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1616 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1617 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1618 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1619 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1620 // Get identity matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1621 RMAPI Matrix MatrixIdentity(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1622 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1623 Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1624 0.0f, 1.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1625 0.0f, 0.0f, 1.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1626 0.0f, 0.0f, 0.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1627 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1628 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1629 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1630 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1631 // Add two matrices |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1632 RMAPI Matrix MatrixAdd(Matrix left, Matrix right) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1633 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1634 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1635 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1636 result.m0 = left.m0 + right.m0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1637 result.m1 = left.m1 + right.m1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1638 result.m2 = left.m2 + right.m2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1639 result.m3 = left.m3 + right.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1640 result.m4 = left.m4 + right.m4; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1641 result.m5 = left.m5 + right.m5; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1642 result.m6 = left.m6 + right.m6; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1643 result.m7 = left.m7 + right.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1644 result.m8 = left.m8 + right.m8; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1645 result.m9 = left.m9 + right.m9; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1646 result.m10 = left.m10 + right.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1647 result.m11 = left.m11 + right.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1648 result.m12 = left.m12 + right.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1649 result.m13 = left.m13 + right.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1650 result.m14 = left.m14 + right.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1651 result.m15 = left.m15 + right.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1652 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1653 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1654 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1655 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1656 // Subtract two matrices (left - right) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1657 RMAPI Matrix MatrixSubtract(Matrix left, Matrix right) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1658 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1659 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1660 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1661 result.m0 = left.m0 - right.m0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1662 result.m1 = left.m1 - right.m1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1663 result.m2 = left.m2 - right.m2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1664 result.m3 = left.m3 - right.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1665 result.m4 = left.m4 - right.m4; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1666 result.m5 = left.m5 - right.m5; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1667 result.m6 = left.m6 - right.m6; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1668 result.m7 = left.m7 - right.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1669 result.m8 = left.m8 - right.m8; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1670 result.m9 = left.m9 - right.m9; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1671 result.m10 = left.m10 - right.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1672 result.m11 = left.m11 - right.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1673 result.m12 = left.m12 - right.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1674 result.m13 = left.m13 - right.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1675 result.m14 = left.m14 - right.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1676 result.m15 = left.m15 - right.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1677 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1678 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1679 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1680 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1681 // Get two matrix multiplication |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1682 // NOTE: When multiplying matrices... the order matters! |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1683 RMAPI Matrix MatrixMultiply(Matrix left, Matrix right) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1684 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1685 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1686 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1687 #if defined(RAYMATH_SSE_ENABLED) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1688 // Load left side and right side |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1689 __m128 c0 = _mm_set_ps(right.m12, right.m8, right.m4, right.m0); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1690 __m128 c1 = _mm_set_ps(right.m13, right.m9, right.m5, right.m1); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1691 __m128 c2 = _mm_set_ps(right.m14, right.m10, right.m6, right.m2); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1692 __m128 c3 = _mm_set_ps(right.m15, right.m11, right.m7, right.m3); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1693 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1694 // Transpose so c0..c3 become *rows* of the right matrix in semantic order |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1695 _MM_TRANSPOSE4_PS(c0, c1, c2, c3); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1696 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1697 float tmp[4] = { 0 }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1698 __m128 row; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1699 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1700 // Row 0 of result: [m0, m1, m2, m3] |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1701 row = _mm_mul_ps(_mm_set1_ps(left.m0), c0); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1702 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m1), c1)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1703 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m2), c2)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1704 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m3), c3)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1705 _mm_storeu_ps(tmp, row); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1706 result.m0 = tmp[0]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1707 result.m1 = tmp[1]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1708 result.m2 = tmp[2]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1709 result.m3 = tmp[3]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1710 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1711 // Row 1 of result: [m4, m5, m6, m7] |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1712 row = _mm_mul_ps(_mm_set1_ps(left.m4), c0); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1713 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m5), c1)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1714 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m6), c2)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1715 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m7), c3)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1716 _mm_storeu_ps(tmp, row); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1717 result.m4 = tmp[0]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1718 result.m5 = tmp[1]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1719 result.m6 = tmp[2]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1720 result.m7 = tmp[3]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1721 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1722 // Row 2 of result: [m8, m9, m10, m11] |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1723 row = _mm_mul_ps(_mm_set1_ps(left.m8), c0); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1724 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m9), c1)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1725 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m10), c2)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1726 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m11), c3)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1727 _mm_storeu_ps(tmp, row); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1728 result.m8 = tmp[0]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1729 result.m9 = tmp[1]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1730 result.m10 = tmp[2]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1731 result.m11 = tmp[3]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1732 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1733 // Row 3 of result: [m12, m13, m14, m15] |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1734 row = _mm_mul_ps(_mm_set1_ps(left.m12), c0); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1735 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m13), c1)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1736 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m14), c2)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1737 row = _mm_add_ps(row, _mm_mul_ps(_mm_set1_ps(left.m15), c3)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1738 _mm_storeu_ps(tmp, row); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1739 result.m12 = tmp[0]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1740 result.m13 = tmp[1]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1741 result.m14 = tmp[2]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1742 result.m15 = tmp[3]; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1743 #else |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1744 result.m0 = left.m0*right.m0 + left.m1*right.m4 + left.m2*right.m8 + left.m3*right.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1745 result.m1 = left.m0*right.m1 + left.m1*right.m5 + left.m2*right.m9 + left.m3*right.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1746 result.m2 = left.m0*right.m2 + left.m1*right.m6 + left.m2*right.m10 + left.m3*right.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1747 result.m3 = left.m0*right.m3 + left.m1*right.m7 + left.m2*right.m11 + left.m3*right.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1748 result.m4 = left.m4*right.m0 + left.m5*right.m4 + left.m6*right.m8 + left.m7*right.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1749 result.m5 = left.m4*right.m1 + left.m5*right.m5 + left.m6*right.m9 + left.m7*right.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1750 result.m6 = left.m4*right.m2 + left.m5*right.m6 + left.m6*right.m10 + left.m7*right.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1751 result.m7 = left.m4*right.m3 + left.m5*right.m7 + left.m6*right.m11 + left.m7*right.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1752 result.m8 = left.m8*right.m0 + left.m9*right.m4 + left.m10*right.m8 + left.m11*right.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1753 result.m9 = left.m8*right.m1 + left.m9*right.m5 + left.m10*right.m9 + left.m11*right.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1754 result.m10 = left.m8*right.m2 + left.m9*right.m6 + left.m10*right.m10 + left.m11*right.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1755 result.m11 = left.m8*right.m3 + left.m9*right.m7 + left.m10*right.m11 + left.m11*right.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1756 result.m12 = left.m12*right.m0 + left.m13*right.m4 + left.m14*right.m8 + left.m15*right.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1757 result.m13 = left.m12*right.m1 + left.m13*right.m5 + left.m14*right.m9 + left.m15*right.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1758 result.m14 = left.m12*right.m2 + left.m13*right.m6 + left.m14*right.m10 + left.m15*right.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1759 result.m15 = left.m12*right.m3 + left.m13*right.m7 + left.m14*right.m11 + left.m15*right.m15; |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1760 #endif |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1761 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1762 return result; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1763 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1764 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1765 // Multiply matrix components by value |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1766 RMAPI Matrix MatrixMultiplyValue(Matrix left, float value) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1767 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1768 Matrix result = { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1769 left.m0*value, left.m4*value, left.m8*value, left.m12*value, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1770 left.m1*value, left.m5*value, left.m9*value, left.m13*value, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1771 left.m2*value, left.m6*value, left.m10*value, left.m14*value, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1772 left.m3*value, left.m7*value, left.m11*value, left.m15*value |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
1773 }; |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1774 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1775 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1776 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1777 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1778 // Get translation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1779 RMAPI Matrix MatrixTranslate(float x, float y, float z) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1780 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1781 Matrix result = { 1.0f, 0.0f, 0.0f, x, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1782 0.0f, 1.0f, 0.0f, y, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1783 0.0f, 0.0f, 1.0f, z, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1784 0.0f, 0.0f, 0.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1785 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1786 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1787 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1788 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1789 // Create rotation matrix from axis and angle |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1790 // NOTE: Angle should be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1791 RMAPI Matrix MatrixRotate(Vector3 axis, float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1792 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1793 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1794 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1795 float x = axis.x, y = axis.y, z = axis.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1796 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1797 float lengthSquared = x*x + y*y + z*z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1798 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1799 if ((lengthSquared != 1.0f) && (lengthSquared != 0.0f)) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1800 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1801 float ilength = 1.0f/sqrtf(lengthSquared); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1802 x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1803 y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1804 z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1805 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1806 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1807 float sinres = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1808 float cosres = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1809 float t = 1.0f - cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1810 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1811 result.m0 = x*x*t + cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1812 result.m1 = y*x*t + z*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1813 result.m2 = z*x*t - y*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1814 result.m3 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1815 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1816 result.m4 = x*y*t - z*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1817 result.m5 = y*y*t + cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1818 result.m6 = z*y*t + x*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1819 result.m7 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1820 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1821 result.m8 = x*z*t + y*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1822 result.m9 = y*z*t - x*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1823 result.m10 = z*z*t + cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1824 result.m11 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1825 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1826 result.m12 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1827 result.m13 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1828 result.m14 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1829 result.m15 = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1830 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1831 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1832 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1833 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1834 // Get x-rotation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1835 // NOTE: Angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1836 RMAPI Matrix MatrixRotateX(float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1837 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1838 Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1839 0.0f, 1.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1840 0.0f, 0.0f, 1.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1841 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity() |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1842 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1843 float cosres = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1844 float sinres = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1845 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1846 result.m5 = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1847 result.m6 = sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1848 result.m9 = -sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1849 result.m10 = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1850 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1851 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1852 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1853 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1854 // Get y-rotation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1855 // NOTE: Angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1856 RMAPI Matrix MatrixRotateY(float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1857 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1858 Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1859 0.0f, 1.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1860 0.0f, 0.0f, 1.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1861 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity() |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1862 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1863 float cosres = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1864 float sinres = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1865 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1866 result.m0 = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1867 result.m2 = -sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1868 result.m8 = sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1869 result.m10 = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1870 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1871 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1872 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1873 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1874 // Get z-rotation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1875 // NOTE: Angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1876 RMAPI Matrix MatrixRotateZ(float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1877 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1878 Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1879 0.0f, 1.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1880 0.0f, 0.0f, 1.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1881 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity() |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1882 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1883 float cosres = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1884 float sinres = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1885 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1886 result.m0 = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1887 result.m1 = sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1888 result.m4 = -sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1889 result.m5 = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1890 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1891 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1892 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1893 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1894 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1895 // Get xyz-rotation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1896 // NOTE: Angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1897 RMAPI Matrix MatrixRotateXYZ(Vector3 angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1898 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1899 Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1900 0.0f, 1.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1901 0.0f, 0.0f, 1.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1902 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity() |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1903 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1904 float cosz = cosf(-angle.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1905 float sinz = sinf(-angle.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1906 float cosy = cosf(-angle.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1907 float siny = sinf(-angle.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1908 float cosx = cosf(-angle.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1909 float sinx = sinf(-angle.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1910 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1911 result.m0 = cosz*cosy; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1912 result.m1 = (cosz*siny*sinx) - (sinz*cosx); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1913 result.m2 = (cosz*siny*cosx) + (sinz*sinx); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1914 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1915 result.m4 = sinz*cosy; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1916 result.m5 = (sinz*siny*sinx) + (cosz*cosx); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1917 result.m6 = (sinz*siny*cosx) - (cosz*sinx); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1918 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1919 result.m8 = -siny; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1920 result.m9 = cosy*sinx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1921 result.m10= cosy*cosx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1922 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1923 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1924 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1925 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1926 // Get zyx-rotation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1927 // NOTE: Angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1928 RMAPI Matrix MatrixRotateZYX(Vector3 angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1929 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1930 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1931 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1932 float cz = cosf(angle.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1933 float sz = sinf(angle.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1934 float cy = cosf(angle.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1935 float sy = sinf(angle.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1936 float cx = cosf(angle.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1937 float sx = sinf(angle.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1938 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1939 result.m0 = cz*cy; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1940 result.m4 = cz*sy*sx - cx*sz; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1941 result.m8 = sz*sx + cz*cx*sy; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1942 result.m12 = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1943 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1944 result.m1 = cy*sz; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1945 result.m5 = cz*cx + sz*sy*sx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1946 result.m9 = cx*sz*sy - cz*sx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1947 result.m13 = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1948 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1949 result.m2 = -sy; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1950 result.m6 = cy*sx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1951 result.m10 = cy*cx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1952 result.m14 = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1953 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1954 result.m3 = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1955 result.m7 = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1956 result.m11 = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1957 result.m15 = 1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1958 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1959 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1960 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1961 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1962 // Get scaling matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1963 RMAPI Matrix MatrixScale(float x, float y, float z) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1964 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1965 Matrix result = { x, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1966 0.0f, y, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1967 0.0f, 0.0f, z, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1968 0.0f, 0.0f, 0.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1969 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1970 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1971 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1972 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1973 // Get perspective projection matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1974 RMAPI Matrix MatrixFrustum(double left, double right, double bottom, double top, double nearPlane, double farPlane) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1975 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1976 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1977 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1978 float rl = (float)(right - left); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1979 float tb = (float)(top - bottom); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1980 float fn = (float)(farPlane - nearPlane); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1981 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1982 result.m0 = ((float)nearPlane*2.0f)/rl; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1983 result.m1 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1984 result.m2 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1985 result.m3 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1986 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1987 result.m4 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1988 result.m5 = ((float)nearPlane*2.0f)/tb; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1989 result.m6 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1990 result.m7 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1991 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1992 result.m8 = ((float)right + (float)left)/rl; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1993 result.m9 = ((float)top + (float)bottom)/tb; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1994 result.m10 = -((float)farPlane + (float)nearPlane)/fn; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1995 result.m11 = -1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1996 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1997 result.m12 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1998 result.m13 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
1999 result.m14 = -((float)farPlane*(float)nearPlane*2.0f)/fn; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2000 result.m15 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2001 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2002 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2003 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2004 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2005 // Get perspective projection matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2006 // NOTE: Fovy angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2007 RMAPI Matrix MatrixPerspective(double fovY, double aspect, double nearPlane, double farPlane) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2008 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2009 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2010 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2011 double top = nearPlane*tan(fovY*0.5); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2012 double bottom = -top; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2013 double right = top*aspect; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2014 double left = -right; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2015 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2016 // MatrixFrustum(-right, right, -top, top, near, far); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2017 float rl = (float)(right - left); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2018 float tb = (float)(top - bottom); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2019 float fn = (float)(farPlane - nearPlane); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2020 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2021 result.m0 = ((float)nearPlane*2.0f)/rl; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2022 result.m5 = ((float)nearPlane*2.0f)/tb; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2023 result.m8 = ((float)right + (float)left)/rl; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2024 result.m9 = ((float)top + (float)bottom)/tb; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2025 result.m10 = -((float)farPlane + (float)nearPlane)/fn; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2026 result.m11 = -1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2027 result.m14 = -((float)farPlane*(float)nearPlane*2.0f)/fn; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2028 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2029 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2030 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2031 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2032 // Get orthographic projection matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2033 RMAPI Matrix MatrixOrtho(double left, double right, double bottom, double top, double nearPlane, double farPlane) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2034 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2035 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2036 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2037 float rl = (float)(right - left); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2038 float tb = (float)(top - bottom); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2039 float fn = (float)(farPlane - nearPlane); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2040 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2041 result.m0 = 2.0f/rl; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2042 result.m1 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2043 result.m2 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2044 result.m3 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2045 result.m4 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2046 result.m5 = 2.0f/tb; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2047 result.m6 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2048 result.m7 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2049 result.m8 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2050 result.m9 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2051 result.m10 = -2.0f/fn; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2052 result.m11 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2053 result.m12 = -((float)left + (float)right)/rl; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2054 result.m13 = -((float)top + (float)bottom)/tb; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2055 result.m14 = -((float)farPlane + (float)nearPlane)/fn; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2056 result.m15 = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2057 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2058 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2059 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2060 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2061 // Get camera look-at matrix (view matrix) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2062 RMAPI Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2063 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2064 Matrix result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2065 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2066 float length = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2067 float ilength = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2068 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2069 // Vector3Subtract(eye, target) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2070 Vector3 vz = { eye.x - target.x, eye.y - target.y, eye.z - target.z }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2071 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2072 // Vector3Normalize(vz) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2073 Vector3 v = vz; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2074 length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2075 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2076 ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2077 vz.x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2078 vz.y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2079 vz.z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2080 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2081 // Vector3CrossProduct(up, vz) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2082 Vector3 vx = { up.y*vz.z - up.z*vz.y, up.z*vz.x - up.x*vz.z, up.x*vz.y - up.y*vz.x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2083 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2084 // Vector3Normalize(x) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2085 v = vx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2086 length = sqrtf(v.x*v.x + v.y*v.y + v.z*v.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2087 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2088 ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2089 vx.x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2090 vx.y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2091 vx.z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2092 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2093 // Vector3CrossProduct(vz, vx) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2094 Vector3 vy = { vz.y*vx.z - vz.z*vx.y, vz.z*vx.x - vz.x*vx.z, vz.x*vx.y - vz.y*vx.x }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2095 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2096 result.m0 = vx.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2097 result.m1 = vy.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2098 result.m2 = vz.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2099 result.m3 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2100 result.m4 = vx.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2101 result.m5 = vy.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2102 result.m6 = vz.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2103 result.m7 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2104 result.m8 = vx.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2105 result.m9 = vy.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2106 result.m10 = vz.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2107 result.m11 = 0.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2108 result.m12 = -(vx.x*eye.x + vx.y*eye.y + vx.z*eye.z); // Vector3DotProduct(vx, eye) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2109 result.m13 = -(vy.x*eye.x + vy.y*eye.y + vy.z*eye.z); // Vector3DotProduct(vy, eye) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2110 result.m14 = -(vz.x*eye.x + vz.y*eye.y + vz.z*eye.z); // Vector3DotProduct(vz, eye) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2111 result.m15 = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2112 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2113 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2114 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2115 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2116 // Get float array of matrix data |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2117 RMAPI float16 MatrixToFloatV(Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2118 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2119 float16 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2120 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2121 result.v[0] = mat.m0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2122 result.v[1] = mat.m1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2123 result.v[2] = mat.m2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2124 result.v[3] = mat.m3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2125 result.v[4] = mat.m4; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2126 result.v[5] = mat.m5; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2127 result.v[6] = mat.m6; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2128 result.v[7] = mat.m7; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2129 result.v[8] = mat.m8; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2130 result.v[9] = mat.m9; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2131 result.v[10] = mat.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2132 result.v[11] = mat.m11; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2133 result.v[12] = mat.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2134 result.v[13] = mat.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2135 result.v[14] = mat.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2136 result.v[15] = mat.m15; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2137 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2138 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2139 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2140 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2141 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2142 // Module Functions Definition - Quaternion math |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2143 //---------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2144 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2145 // Add two quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2146 RMAPI Quaternion QuaternionAdd(Quaternion q1, Quaternion q2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2147 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2148 Quaternion result = {q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2149 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2150 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2151 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2152 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2153 // Add quaternion and float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2154 RMAPI Quaternion QuaternionAddValue(Quaternion q, float add) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2155 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2156 Quaternion result = {q.x + add, q.y + add, q.z + add, q.w + add}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2157 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2158 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2159 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2160 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2161 // Subtract two quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2162 RMAPI Quaternion QuaternionSubtract(Quaternion q1, Quaternion q2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2163 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2164 Quaternion result = {q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2165 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2166 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2167 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2168 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2169 // Subtract quaternion and float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2170 RMAPI Quaternion QuaternionSubtractValue(Quaternion q, float sub) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2171 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2172 Quaternion result = {q.x - sub, q.y - sub, q.z - sub, q.w - sub}; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2173 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2174 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2175 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2176 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2177 // Get identity quaternion |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2178 RMAPI Quaternion QuaternionIdentity(void) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2179 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2180 Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2181 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2182 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2183 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2184 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2185 // Computes the length of a quaternion |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2186 RMAPI float QuaternionLength(Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2187 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2188 float result = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2189 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2190 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2191 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2192 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2193 // Normalize provided quaternion |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2194 RMAPI Quaternion QuaternionNormalize(Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2195 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2196 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2197 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2198 float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2199 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2200 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2201 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2202 result.x = q.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2203 result.y = q.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2204 result.z = q.z*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2205 result.w = q.w*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2206 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2207 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2208 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2209 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2210 // Invert provided quaternion |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2211 RMAPI Quaternion QuaternionInvert(Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2212 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2213 Quaternion result = q; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2214 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2215 float lengthSq = q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2216 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2217 if (lengthSq != 0.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2218 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2219 float invLength = 1.0f/lengthSq; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2220 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2221 result.x *= -invLength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2222 result.y *= -invLength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2223 result.z *= -invLength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2224 result.w *= invLength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2225 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2226 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2227 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2228 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2229 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2230 // Calculate two quaternion multiplication |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2231 RMAPI Quaternion QuaternionMultiply(Quaternion q1, Quaternion q2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2232 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2233 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2234 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2235 float qax = q1.x, qay = q1.y, qaz = q1.z, qaw = q1.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2236 float qbx = q2.x, qby = q2.y, qbz = q2.z, qbw = q2.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2237 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2238 result.x = qax*qbw + qaw*qbx + qay*qbz - qaz*qby; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2239 result.y = qay*qbw + qaw*qby + qaz*qbx - qax*qbz; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2240 result.z = qaz*qbw + qaw*qbz + qax*qby - qay*qbx; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2241 result.w = qaw*qbw - qax*qbx - qay*qby - qaz*qbz; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2242 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2243 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2244 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2245 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2246 // Scale quaternion by float value |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2247 RMAPI Quaternion QuaternionScale(Quaternion q, float mul) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2248 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2249 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2250 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2251 result.x = q.x*mul; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2252 result.y = q.y*mul; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2253 result.z = q.z*mul; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2254 result.w = q.w*mul; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2255 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2256 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2257 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2258 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2259 // Divide two quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2260 RMAPI Quaternion QuaternionDivide(Quaternion q1, Quaternion q2) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2261 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2262 Quaternion result = { q1.x/q2.x, q1.y/q2.y, q1.z/q2.z, q1.w/q2.w }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2263 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2264 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2265 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2266 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2267 // Calculate linear interpolation between two quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2268 RMAPI Quaternion QuaternionLerp(Quaternion q1, Quaternion q2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2269 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2270 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2271 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2272 result.x = q1.x + amount*(q2.x - q1.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2273 result.y = q1.y + amount*(q2.y - q1.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2274 result.z = q1.z + amount*(q2.z - q1.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2275 result.w = q1.w + amount*(q2.w - q1.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2276 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2277 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2278 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2279 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2280 // Calculate slerp-optimized interpolation between two quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2281 RMAPI Quaternion QuaternionNlerp(Quaternion q1, Quaternion q2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2282 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2283 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2284 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2285 // QuaternionLerp(q1, q2, amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2286 result.x = q1.x + amount*(q2.x - q1.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2287 result.y = q1.y + amount*(q2.y - q1.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2288 result.z = q1.z + amount*(q2.z - q1.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2289 result.w = q1.w + amount*(q2.w - q1.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2290 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2291 // QuaternionNormalize(q); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2292 Quaternion q = result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2293 float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2294 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2295 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2296 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2297 result.x = q.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2298 result.y = q.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2299 result.z = q.z*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2300 result.w = q.w*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2301 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2302 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2303 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2304 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2305 // Calculates spherical linear interpolation between two quaternions |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2306 RMAPI Quaternion QuaternionSlerp(Quaternion q1, Quaternion q2, float amount) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2307 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2308 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2309 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2310 #if !defined(EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2311 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2312 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2313 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2314 float cosHalfTheta = q1.x*q2.x + q1.y*q2.y + q1.z*q2.z + q1.w*q2.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2315 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2316 if (cosHalfTheta < 0) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2317 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2318 q2.x = -q2.x; q2.y = -q2.y; q2.z = -q2.z; q2.w = -q2.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2319 cosHalfTheta = -cosHalfTheta; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2320 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2321 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2322 if (fabsf(cosHalfTheta) >= 1.0f) result = q1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2323 else if (cosHalfTheta > 0.95f) result = QuaternionNlerp(q1, q2, amount); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2324 else |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2325 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2326 float halfTheta = acosf(cosHalfTheta); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2327 float sinHalfTheta = sqrtf(1.0f - cosHalfTheta*cosHalfTheta); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2328 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2329 if (fabsf(sinHalfTheta) < EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2330 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2331 result.x = (q1.x*0.5f + q2.x*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2332 result.y = (q1.y*0.5f + q2.y*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2333 result.z = (q1.z*0.5f + q2.z*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2334 result.w = (q1.w*0.5f + q2.w*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2335 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2336 else |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2337 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2338 float ratioA = sinf((1 - amount)*halfTheta)/sinHalfTheta; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2339 float ratioB = sinf(amount*halfTheta)/sinHalfTheta; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2340 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2341 result.x = (q1.x*ratioA + q2.x*ratioB); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2342 result.y = (q1.y*ratioA + q2.y*ratioB); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2343 result.z = (q1.z*ratioA + q2.z*ratioB); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2344 result.w = (q1.w*ratioA + q2.w*ratioB); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2345 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2346 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2347 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2348 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2349 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2350 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2351 // Calculate quaternion cubic spline interpolation using Cubic Hermite Spline algorithm |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2352 // as described in the GLTF 2.0 specification: https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#interpolation-cubic |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2353 RMAPI Quaternion QuaternionCubicHermiteSpline(Quaternion q1, Quaternion outTangent1, Quaternion q2, Quaternion inTangent2, float t) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2354 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2355 float t2 = t*t; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2356 float t3 = t2*t; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2357 float h00 = 2*t3 - 3*t2 + 1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2358 float h10 = t3 - 2*t2 + t; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2359 float h01 = -2*t3 + 3*t2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2360 float h11 = t3 - t2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2361 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2362 Quaternion p0 = QuaternionScale(q1, h00); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2363 Quaternion m0 = QuaternionScale(outTangent1, h10); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2364 Quaternion p1 = QuaternionScale(q2, h01); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2365 Quaternion m1 = QuaternionScale(inTangent2, h11); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2366 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2367 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2368 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2369 result = QuaternionAdd(p0, m0); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2370 result = QuaternionAdd(result, p1); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2371 result = QuaternionAdd(result, m1); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2372 result = QuaternionNormalize(result); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2373 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2374 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2375 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2376 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2377 // Calculate quaternion based on the rotation from one vector to another |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2378 RMAPI Quaternion QuaternionFromVector3ToVector3(Vector3 from, Vector3 to) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2379 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2380 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2381 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2382 float cos2Theta = (from.x*to.x + from.y*to.y + from.z*to.z); // Vector3DotProduct(from, to) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2383 Vector3 cross = { from.y*to.z - from.z*to.y, from.z*to.x - from.x*to.z, from.x*to.y - from.y*to.x }; // Vector3CrossProduct(from, to) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2384 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2385 result.x = cross.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2386 result.y = cross.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2387 result.z = cross.z; |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2388 result.w = sqrtf(cross.x*cross.x + cross.y*cross.y + cross.z*cross.z + cos2Theta*cos2Theta) + cos2Theta; |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2389 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2390 // QuaternionNormalize(q); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2391 // NOTE: Normalize to essentially nlerp the original and identity to 0.5 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2392 Quaternion q = result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2393 float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2394 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2395 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2396 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2397 result.x = q.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2398 result.y = q.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2399 result.z = q.z*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2400 result.w = q.w*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2401 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2402 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2403 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2404 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2405 // Get a quaternion for a given rotation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2406 RMAPI Quaternion QuaternionFromMatrix(Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2407 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2408 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2409 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2410 float fourWSquaredMinus1 = mat.m0 + mat.m5 + mat.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2411 float fourXSquaredMinus1 = mat.m0 - mat.m5 - mat.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2412 float fourYSquaredMinus1 = mat.m5 - mat.m0 - mat.m10; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2413 float fourZSquaredMinus1 = mat.m10 - mat.m0 - mat.m5; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2414 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2415 int biggestIndex = 0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2416 float fourBiggestSquaredMinus1 = fourWSquaredMinus1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2417 if (fourXSquaredMinus1 > fourBiggestSquaredMinus1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2418 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2419 fourBiggestSquaredMinus1 = fourXSquaredMinus1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2420 biggestIndex = 1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2421 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2422 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2423 if (fourYSquaredMinus1 > fourBiggestSquaredMinus1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2424 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2425 fourBiggestSquaredMinus1 = fourYSquaredMinus1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2426 biggestIndex = 2; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2427 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2428 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2429 if (fourZSquaredMinus1 > fourBiggestSquaredMinus1) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2430 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2431 fourBiggestSquaredMinus1 = fourZSquaredMinus1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2432 biggestIndex = 3; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2433 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2434 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2435 float biggestVal = sqrtf(fourBiggestSquaredMinus1 + 1.0f)*0.5f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2436 float mult = 0.25f/biggestVal; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2437 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2438 switch (biggestIndex) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2439 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2440 case 0: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2441 result.w = biggestVal; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2442 result.x = (mat.m6 - mat.m9)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2443 result.y = (mat.m8 - mat.m2)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2444 result.z = (mat.m1 - mat.m4)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2445 break; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2446 case 1: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2447 result.x = biggestVal; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2448 result.w = (mat.m6 - mat.m9)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2449 result.y = (mat.m1 + mat.m4)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2450 result.z = (mat.m8 + mat.m2)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2451 break; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2452 case 2: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2453 result.y = biggestVal; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2454 result.w = (mat.m8 - mat.m2)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2455 result.x = (mat.m1 + mat.m4)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2456 result.z = (mat.m6 + mat.m9)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2457 break; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2458 case 3: |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2459 result.z = biggestVal; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2460 result.w = (mat.m1 - mat.m4)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2461 result.x = (mat.m8 + mat.m2)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2462 result.y = (mat.m6 + mat.m9)*mult; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2463 break; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2464 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2465 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2466 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2467 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2468 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2469 // Get a matrix for a given quaternion |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2470 RMAPI Matrix QuaternionToMatrix(Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2471 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2472 Matrix result = { 1.0f, 0.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2473 0.0f, 1.0f, 0.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2474 0.0f, 0.0f, 1.0f, 0.0f, |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2475 0.0f, 0.0f, 0.0f, 1.0f }; // MatrixIdentity() |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2476 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2477 float a2 = q.x*q.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2478 float b2 = q.y*q.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2479 float c2 = q.z*q.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2480 float ac = q.x*q.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2481 float ab = q.x*q.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2482 float bc = q.y*q.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2483 float ad = q.w*q.x; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2484 float bd = q.w*q.y; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2485 float cd = q.w*q.z; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2486 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2487 result.m0 = 1 - 2*(b2 + c2); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2488 result.m1 = 2*(ab + cd); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2489 result.m2 = 2*(ac - bd); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2490 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2491 result.m4 = 2*(ab - cd); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2492 result.m5 = 1 - 2*(a2 + c2); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2493 result.m6 = 2*(bc + ad); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2494 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2495 result.m8 = 2*(ac + bd); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2496 result.m9 = 2*(bc - ad); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2497 result.m10 = 1 - 2*(a2 + b2); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2498 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2499 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2500 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2501 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2502 // Get rotation quaternion for an angle and axis |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2503 // NOTE: Angle must be provided in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2504 RMAPI Quaternion QuaternionFromAxisAngle(Vector3 axis, float angle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2505 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2506 Quaternion result = { 0.0f, 0.0f, 0.0f, 1.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2507 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2508 float length = sqrtf(axis.x*axis.x + axis.y*axis.y + axis.z*axis.z); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2509 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2510 if (length != 0.0f) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2511 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2512 angle *= 0.5f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2513 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2514 // Vector3Normalize(axis) |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2515 float ilength = 1.0f/length; |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2516 axis.x *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2517 axis.y *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2518 axis.z *= ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2519 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2520 float sinres = sinf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2521 float cosres = cosf(angle); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2522 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2523 result.x = axis.x*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2524 result.y = axis.y*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2525 result.z = axis.z*sinres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2526 result.w = cosres; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2527 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2528 // QuaternionNormalize(q); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2529 Quaternion q = result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2530 length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2531 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2532 ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2533 result.x = q.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2534 result.y = q.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2535 result.z = q.z*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2536 result.w = q.w*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2537 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2538 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2539 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2540 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2541 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2542 // Get the rotation angle and axis for a given quaternion |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2543 RMAPI void QuaternionToAxisAngle(Quaternion q, Vector3 *outAxis, float *outAngle) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2544 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2545 if (fabsf(q.w) > 1.0f) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2546 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2547 // QuaternionNormalize(q); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2548 float length = sqrtf(q.x*q.x + q.y*q.y + q.z*q.z + q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2549 if (length == 0.0f) length = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2550 float ilength = 1.0f/length; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2551 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2552 q.x = q.x*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2553 q.y = q.y*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2554 q.z = q.z*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2555 q.w = q.w*ilength; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2556 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2557 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2558 Vector3 resAxis = { 0.0f, 0.0f, 0.0f }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2559 float resAngle = 2.0f*acosf(q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2560 float den = sqrtf(1.0f - q.w*q.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2561 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2562 if (den > EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2563 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2564 resAxis.x = q.x/den; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2565 resAxis.y = q.y/den; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2566 resAxis.z = q.z/den; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2567 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2568 else |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2569 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2570 // This occurs when the angle is zero |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2571 // Not a problem, set an arbitrary normalized axis |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2572 resAxis.x = 1.0f; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2573 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2574 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2575 *outAxis = resAxis; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2576 *outAngle = resAngle; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2577 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2578 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2579 // Get the quaternion equivalent to Euler angles |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2580 // NOTE: Rotation order is ZYX |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2581 RMAPI Quaternion QuaternionFromEuler(float pitch, float yaw, float roll) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2582 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2583 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2584 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2585 float x0 = cosf(pitch*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2586 float x1 = sinf(pitch*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2587 float y0 = cosf(yaw*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2588 float y1 = sinf(yaw*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2589 float z0 = cosf(roll*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2590 float z1 = sinf(roll*0.5f); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2591 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2592 result.x = x1*y0*z0 - x0*y1*z1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2593 result.y = x0*y1*z0 + x1*y0*z1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2594 result.z = x0*y0*z1 - x1*y1*z0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2595 result.w = x0*y0*z0 + x1*y1*z1; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2596 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2597 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2598 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2599 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2600 // Get the Euler angles equivalent to quaternion (roll, pitch, yaw) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2601 // NOTE: Angles are returned in a Vector3 struct in radians |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2602 RMAPI Vector3 QuaternionToEuler(Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2603 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2604 Vector3 result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2605 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2606 // Roll (x-axis rotation) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2607 float x0 = 2.0f*(q.w*q.x + q.y*q.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2608 float x1 = 1.0f - 2.0f*(q.x*q.x + q.y*q.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2609 result.x = atan2f(x0, x1); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2610 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2611 // Pitch (y-axis rotation) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2612 float y0 = 2.0f*(q.w*q.y - q.z*q.x); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2613 y0 = y0 > 1.0f ? 1.0f : y0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2614 y0 = y0 < -1.0f ? -1.0f : y0; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2615 result.y = asinf(y0); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2616 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2617 // Yaw (z-axis rotation) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2618 float z0 = 2.0f*(q.w*q.z + q.x*q.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2619 float z1 = 1.0f - 2.0f*(q.y*q.y + q.z*q.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2620 result.z = atan2f(z0, z1); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2621 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2622 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2623 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2624 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2625 // Transform a quaternion given a transformation matrix |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2626 RMAPI Quaternion QuaternionTransform(Quaternion q, Matrix mat) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2627 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2628 Quaternion result = { 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2629 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2630 result.x = mat.m0*q.x + mat.m4*q.y + mat.m8*q.z + mat.m12*q.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2631 result.y = mat.m1*q.x + mat.m5*q.y + mat.m9*q.z + mat.m13*q.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2632 result.z = mat.m2*q.x + mat.m6*q.y + mat.m10*q.z + mat.m14*q.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2633 result.w = mat.m3*q.x + mat.m7*q.y + mat.m11*q.z + mat.m15*q.w; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2634 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2635 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2636 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2637 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2638 // Check whether two given quaternions are almost equal |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2639 RMAPI int QuaternionEquals(Quaternion p, Quaternion q) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2640 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2641 #if !defined(EPSILON) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2642 #define EPSILON 0.000001f |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2643 #endif |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2644 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2645 int result = (((fabsf(p.x - q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2646 ((fabsf(p.y - q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2647 ((fabsf(p.z - q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2648 ((fabsf(p.w - q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))) || |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2649 (((fabsf(p.x + q.x)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.x), fabsf(q.x))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2650 ((fabsf(p.y + q.y)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.y), fabsf(q.y))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2651 ((fabsf(p.z + q.z)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.z), fabsf(q.z))))) && |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2652 ((fabsf(p.w + q.w)) <= (EPSILON*fmaxf(1.0f, fmaxf(fabsf(p.w), fabsf(q.w)))))); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2653 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2654 return result; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2655 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2656 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2657 // Compose a transformation matrix from rotational, translational and scaling components |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2658 // TODO: This function is not following raymath conventions defined in header: NOT self-contained |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2659 RMAPI Matrix MatrixCompose(Vector3 translation, Quaternion rotation, Vector3 scale) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2660 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2661 // Initialize vectors |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2662 Vector3 right = { 1.0f, 0.0f, 0.0f }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2663 Vector3 up = { 0.0f, 1.0f, 0.0f }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2664 Vector3 forward = { 0.0f, 0.0f, 1.0f }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2665 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2666 // Scale vectors |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2667 right = Vector3Scale(right, scale.x); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2668 up = Vector3Scale(up, scale.y); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2669 forward = Vector3Scale(forward , scale.z); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2670 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2671 // Rotate vectors |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2672 right = Vector3RotateByQuaternion(right, rotation); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2673 up = Vector3RotateByQuaternion(up, rotation); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2674 forward = Vector3RotateByQuaternion(forward, rotation); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2675 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2676 // Set result matrix output |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2677 Matrix result = { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2678 right.x, up.x, forward.x, translation.x, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2679 right.y, up.y, forward.y, translation.y, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2680 right.z, up.z, forward.z, translation.z, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2681 0.0f, 0.0f, 0.0f, 1.0f |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2682 }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2683 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2684 return result; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2685 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2686 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2687 // Decompose a transformation matrix into its rotational, translational and scaling components and remove shear |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2688 // TODO: This function is not following raymath conventions defined in header: NOT self-contained |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2689 RMAPI void MatrixDecompose(Matrix mat, Vector3 *translation, Quaternion *rotation, Vector3 *scale) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2690 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2691 float eps = (float)1e-9; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2692 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2693 // Extract Translation |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2694 translation->x = mat.m12; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2695 translation->y = mat.m13; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2696 translation->z = mat.m14; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2697 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2698 // Matrix Columns - Rotation will be extracted into here |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2699 Vector3 matColumns[3] = {{ mat.m0, mat.m4, mat.m8 }, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2700 { mat.m1, mat.m5, mat.m9 }, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2701 { mat.m2, mat.m6, mat.m10 }}; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2702 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2703 // Shear Parameters XY, XZ, and YZ (extract and ignored) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2704 float shear[3] = { 0 }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2705 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2706 // Normalized Scale Parameters |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2707 Vector3 scl = { 0 }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2708 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2709 // Max-Normalizing helps numerical stability |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2710 float stabilizer = eps; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2711 for (int i = 0; i < 3; i++) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2712 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2713 stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].x)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2714 stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].y)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2715 stabilizer = fmaxf(stabilizer, fabsf(matColumns[i].z)); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2716 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2717 matColumns[0] = Vector3Scale(matColumns[0], 1.0f / stabilizer); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2718 matColumns[1] = Vector3Scale(matColumns[1], 1.0f / stabilizer); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2719 matColumns[2] = Vector3Scale(matColumns[2], 1.0f / stabilizer); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2720 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2721 // X Scale |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2722 scl.x = Vector3Length(matColumns[0]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2723 if (scl.x > eps) matColumns[0] = Vector3Scale(matColumns[0], 1.0f / scl.x); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2724 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2725 // Compute XY shear and make col2 orthogonal |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2726 shear[0] = Vector3DotProduct(matColumns[0], matColumns[1]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2727 matColumns[1] = Vector3Subtract(matColumns[1], Vector3Scale(matColumns[0], shear[0])); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2728 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2729 // Y Scale |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2730 scl.y = Vector3Length(matColumns[1]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2731 if (scl.y > eps) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2732 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2733 matColumns[1] = Vector3Scale(matColumns[1], 1.0f / scl.y); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2734 shear[0] /= scl.y; // Correct XY shear |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2735 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2736 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2737 // Compute XZ and YZ shears and make col3 orthogonal |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2738 shear[1] = Vector3DotProduct(matColumns[0], matColumns[2]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2739 matColumns[2] = Vector3Subtract(matColumns[2], Vector3Scale(matColumns[0], shear[1])); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2740 shear[2] = Vector3DotProduct(matColumns[1], matColumns[2]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2741 matColumns[2] = Vector3Subtract(matColumns[2], Vector3Scale(matColumns[1], shear[2])); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2742 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2743 // Z Scale |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2744 scl.z = Vector3Length(matColumns[2]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2745 if (scl.z > eps) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2746 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2747 matColumns[2] = Vector3Scale(matColumns[2], 1.0f / scl.z); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2748 shear[1] /= scl.z; // Correct XZ shear |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2749 shear[2] /= scl.z; // Correct YZ shear |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2750 } |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2751 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2752 // matColumns are now orthonormal in O(3). Now ensure its in SO(3) by enforcing det = 1 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2753 if (Vector3DotProduct(matColumns[0], Vector3CrossProduct(matColumns[1], matColumns[2])) < 0) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2754 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2755 scl = Vector3Negate(scl); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2756 matColumns[0] = Vector3Negate(matColumns[0]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2757 matColumns[1] = Vector3Negate(matColumns[1]); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2758 matColumns[2] = Vector3Negate(matColumns[2]); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2759 } |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2760 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2761 // Set Scale |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2762 *scale = Vector3Scale(scl, stabilizer); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2763 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2764 // Extract Rotation |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2765 Matrix rotationMatrix = { matColumns[0].x, matColumns[0].y, matColumns[0].z, 0, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2766 matColumns[1].x, matColumns[1].y, matColumns[1].z, 0, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2767 matColumns[2].x, matColumns[2].y, matColumns[2].z, 0, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2768 0, 0, 0, 1 }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2769 *rotation = QuaternionFromMatrix(rotationMatrix); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2770 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2771 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2772 #if defined(__cplusplus) && !defined(RAYMATH_DISABLE_CPP_OPERATORS) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2773 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2774 // Optional C++ math operators |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2775 //------------------------------------------------------------------------------- |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2776 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2777 // Vector2 operators |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2778 static constexpr Vector2 Vector2Zeros = { 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2779 static constexpr Vector2 Vector2Ones = { 1, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2780 static constexpr Vector2 Vector2UnitX = { 1, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2781 static constexpr Vector2 Vector2UnitY = { 0, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2782 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2783 inline Vector2 operator + (const Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2784 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2785 return Vector2Add(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2786 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2787 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2788 inline const Vector2& operator += (Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2789 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2790 lhs = Vector2Add(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2791 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2792 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2793 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2794 inline Vector2 operator - (const Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2795 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2796 return Vector2Subtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2797 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2798 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2799 inline const Vector2& operator -= (Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2800 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2801 lhs = Vector2Subtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2802 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2803 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2804 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2805 inline Vector2 operator * (const Vector2& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2806 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2807 return Vector2Scale(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2808 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2809 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2810 inline const Vector2& operator *= (Vector2& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2811 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2812 lhs = Vector2Scale(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2813 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2814 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2815 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2816 inline Vector2 operator * (const Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2817 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2818 return Vector2Multiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2819 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2820 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2821 inline const Vector2& operator *= (Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2822 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2823 lhs = Vector2Multiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2824 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2825 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2826 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2827 inline Vector2 operator * (const Vector2& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2828 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2829 return Vector2Transform(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2830 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2831 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2832 inline const Vector2& operator *= (Vector2& lhs, const Matrix& rhs) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2833 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2834 lhs = Vector2Transform(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2835 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2836 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2837 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2838 inline Vector2 operator / (const Vector2& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2839 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2840 return Vector2Scale(lhs, 1.0f/rhs); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2841 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2842 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2843 inline const Vector2& operator /= (Vector2& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2844 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2845 lhs = Vector2Scale(lhs, 1.0f/rhs); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2846 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2847 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2848 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2849 inline Vector2 operator / (const Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2850 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2851 return Vector2Divide(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2852 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2853 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2854 inline const Vector2& operator /= (Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2855 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2856 lhs = Vector2Divide(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2857 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2858 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2859 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2860 inline bool operator == (const Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2861 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2862 return FloatEquals(lhs.x, rhs.x) && FloatEquals(lhs.y, rhs.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2863 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2864 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2865 inline bool operator != (const Vector2& lhs, const Vector2& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2866 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2867 return !FloatEquals(lhs.x, rhs.x) || !FloatEquals(lhs.y, rhs.y); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2868 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2869 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2870 // Vector3 operators |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2871 static constexpr Vector3 Vector3Zeros = { 0, 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2872 static constexpr Vector3 Vector3Ones = { 1, 1, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2873 static constexpr Vector3 Vector3UnitX = { 1, 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2874 static constexpr Vector3 Vector3UnitY = { 0, 1, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2875 static constexpr Vector3 Vector3UnitZ = { 0, 0, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2876 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2877 inline Vector3 operator + (const Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2878 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2879 return Vector3Add(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2880 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2881 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2882 inline const Vector3& operator += (Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2883 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2884 lhs = Vector3Add(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2885 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2886 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2887 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2888 inline Vector3 operator - (const Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2889 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2890 return Vector3Subtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2891 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2892 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2893 inline const Vector3& operator -= (Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2894 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2895 lhs = Vector3Subtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2896 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2897 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2898 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2899 inline Vector3 operator * (const Vector3& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2900 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2901 return Vector3Scale(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2902 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2903 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2904 inline const Vector3& operator *= (Vector3& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2905 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2906 lhs = Vector3Scale(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2907 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2908 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2909 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2910 inline Vector3 operator * (const Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2911 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2912 return Vector3Multiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2913 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2914 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2915 inline const Vector3& operator *= (Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2916 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2917 lhs = Vector3Multiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2918 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2919 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2920 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2921 inline Vector3 operator * (const Vector3& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2922 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2923 return Vector3Transform(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2924 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2925 |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2926 inline const Vector3& operator *= (Vector3& lhs, const Matrix& rhs) |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2927 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2928 lhs = Vector3Transform(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2929 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2930 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2931 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2932 inline Vector3 operator / (const Vector3& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2933 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2934 return Vector3Scale(lhs, 1.0f/rhs); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2935 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2936 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2937 inline const Vector3& operator /= (Vector3& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2938 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
2939 lhs = Vector3Scale(lhs, 1.0f/rhs); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2940 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2941 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2942 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2943 inline Vector3 operator / (const Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2944 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2945 return Vector3Divide(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2946 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2947 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2948 inline const Vector3& operator /= (Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2949 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2950 lhs = Vector3Divide(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2951 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2952 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2953 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2954 inline bool operator == (const Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2955 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2956 return FloatEquals(lhs.x, rhs.x) && FloatEquals(lhs.y, rhs.y) && FloatEquals(lhs.z, rhs.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2957 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2958 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2959 inline bool operator != (const Vector3& lhs, const Vector3& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2960 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2961 return !FloatEquals(lhs.x, rhs.x) || !FloatEquals(lhs.y, rhs.y) || !FloatEquals(lhs.z, rhs.z); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2962 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2963 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2964 // Vector4 operators |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2965 static constexpr Vector4 Vector4Zeros = { 0, 0, 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2966 static constexpr Vector4 Vector4Ones = { 1, 1, 1, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2967 static constexpr Vector4 Vector4UnitX = { 1, 0, 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2968 static constexpr Vector4 Vector4UnitY = { 0, 1, 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2969 static constexpr Vector4 Vector4UnitZ = { 0, 0, 1, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2970 static constexpr Vector4 Vector4UnitW = { 0, 0, 0, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2971 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2972 inline Vector4 operator + (const Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2973 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2974 return Vector4Add(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2975 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2976 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2977 inline const Vector4& operator += (Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2978 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2979 lhs = Vector4Add(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2980 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2981 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2982 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2983 inline Vector4 operator - (const Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2984 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2985 return Vector4Subtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2986 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2987 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2988 inline const Vector4& operator -= (Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2989 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2990 lhs = Vector4Subtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2991 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2992 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2993 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2994 inline Vector4 operator * (const Vector4& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2995 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2996 return Vector4Scale(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2997 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2998 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
2999 inline const Vector4& operator *= (Vector4& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3000 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3001 lhs = Vector4Scale(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3002 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3003 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3004 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3005 inline Vector4 operator * (const Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3006 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3007 return Vector4Multiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3008 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3009 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3010 inline const Vector4& operator *= (Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3011 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3012 lhs = Vector4Multiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3013 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3014 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3015 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3016 inline Vector4 operator / (const Vector4& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3017 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3018 return Vector4Scale(lhs, 1.0f/rhs); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3019 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3020 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3021 inline const Vector4& operator /= (Vector4& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3022 { |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3023 lhs = Vector4Scale(lhs, 1.0f/rhs); |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3024 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3025 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3026 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3027 inline Vector4 operator / (const Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3028 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3029 return Vector4Divide(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3030 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3031 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3032 inline const Vector4& operator /= (Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3033 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3034 lhs = Vector4Divide(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3035 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3036 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3037 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3038 inline bool operator == (const Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3039 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3040 return FloatEquals(lhs.x, rhs.x) && FloatEquals(lhs.y, rhs.y) && FloatEquals(lhs.z, rhs.z) && FloatEquals(lhs.w, rhs.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3041 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3042 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3043 inline bool operator != (const Vector4& lhs, const Vector4& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3044 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3045 return !FloatEquals(lhs.x, rhs.x) || !FloatEquals(lhs.y, rhs.y) || !FloatEquals(lhs.z, rhs.z) || !FloatEquals(lhs.w, rhs.w); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3046 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3047 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3048 // Quaternion operators |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3049 static constexpr Quaternion QuaternionZeros = { 0, 0, 0, 0 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3050 static constexpr Quaternion QuaternionOnes = { 1, 1, 1, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3051 static constexpr Quaternion QuaternionUnitX = { 0, 0, 0, 1 }; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3052 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3053 inline Quaternion operator + (const Quaternion& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3054 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3055 return QuaternionAddValue(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3056 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3057 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3058 inline const Quaternion& operator += (Quaternion& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3059 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3060 lhs = QuaternionAddValue(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3061 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3062 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3063 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3064 inline Quaternion operator - (const Quaternion& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3065 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3066 return QuaternionSubtractValue(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3067 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3068 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3069 inline const Quaternion& operator -= (Quaternion& lhs, const float& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3070 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3071 lhs = QuaternionSubtractValue(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3072 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3073 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3074 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3075 inline Quaternion operator * (const Quaternion& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3076 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3077 return QuaternionTransform(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3078 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3079 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3080 inline const Quaternion& operator *= (Quaternion& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3081 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3082 lhs = QuaternionTransform(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3083 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3084 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3085 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3086 // Matrix operators |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3087 static constexpr Matrix MatrixUnit = { 1, 0, 0, 0, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3088 0, 1, 0, 0, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3089 0, 0, 1, 0, |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3090 0, 0, 0, 1 }; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3091 |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3092 inline Matrix operator + (const Matrix& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3093 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3094 return MatrixAdd(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3095 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3096 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3097 inline const Matrix& operator += (Matrix& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3098 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3099 lhs = MatrixAdd(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3100 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3101 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3102 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3103 inline Matrix operator - (const Matrix& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3104 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3105 return MatrixSubtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3106 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3107 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3108 inline const Matrix& operator -= (Matrix& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3109 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3110 lhs = MatrixSubtract(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3111 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3112 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3113 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3114 inline Matrix operator * (const Matrix& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3115 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3116 return MatrixMultiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3117 } |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3118 |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3119 inline const Matrix& operator *= (Matrix& lhs, const Matrix& rhs) |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3120 { |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3121 lhs = MatrixMultiply(lhs, rhs); |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3122 return lhs; |
|
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3123 } |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3124 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3125 inline Matrix operator * (const Matrix& lhs, const float value) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3126 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3127 return MatrixMultiplyValue(lhs, value); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3128 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3129 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3130 inline const Matrix& operator *= (Matrix& lhs, const float value) |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3131 { |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3132 lhs = MatrixMultiplyValue(lhs, value); |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3133 return lhs; |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3134 } |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3135 |
|
11
f33d9ff8b6e8
[Raylib] Added raylib linux to third party lib and added cross platform support.
June Park <parkjune1995@gmail.com>
parents:
diff
changeset
|
3136 //------------------------------------------------------------------------------- |
|
276
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3137 #endif // C++ operators |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3138 |
|
b55c22cff335
Add interactive infinite canvas prototype
MrJuneJune <me@mrjunejune.com>
parents:
11
diff
changeset
|
3139 #endif // RAYMATH_H |