math: add cycle180 and cycle360

main
Dominik Madarász 2024-09-04 00:21:46 +02:00
parent 9e12dbb10e
commit e53796415a
7 changed files with 51 additions and 1 deletions

View File

@ -88,6 +88,8 @@ typedef float mat44[16];
float simplex4( vec4 xyzw ); float simplex4( vec4 xyzw );
float deg (float radians); float deg (float radians);
float rad (float degrees); float rad (float degrees);
float cycle180 (float angle);
float cycle360 (float angle);
int mini (int a, int b); int mini (int a, int b);
int maxi (int a, int b); int maxi (int a, int b);
int absi (int a ); int absi (int a );

2
depot

@ -1 +1 @@
Subproject commit 3abeaa482c1c2f88db6bf5816456d5e2e1faa6fb Subproject commit 6d764dd6019192b1efbf1018bc685bb2a8e495c3

View File

@ -14944,6 +14944,9 @@ API float simplex4( vec4 xyzw );
API float deg (float radians); API float deg (float radians);
API float rad (float degrees); API float rad (float degrees);
API float cycle180 (float angle);
API float cycle360 (float angle);
API int mini (int a, int b); API int mini (int a, int b);
API int maxi (int a, int b); API int maxi (int a, int b);
API int absi (int a ); API int absi (int a );
@ -377201,6 +377204,19 @@ float simplex4( vec4 v ) { return snoise4(v.x,v.y,v.z,v.w); }
float deg (float radians) { return radians / C_PI * 180.0f; } float deg (float radians) { return radians / C_PI * 180.0f; }
float rad (float degrees) { return degrees * C_PI / 180.0f; } float rad (float degrees) { return degrees * C_PI / 180.0f; }
float cycle180 (float angle) {
angle = fmod(angle, 360.0f);
if (angle > 180.0f) angle -= 360.0f;
if (angle < -180.0f) angle += 360.0f;
return angle;
}
float cycle360 (float angle) {
angle = fmod(angle, 360.0f);
if (angle < 0.0f) angle += 360.0f;
return angle;
}
int mini (int a, int b) { return a < b ? a : b; } int mini (int a, int b) { return a < b ? a : b; }
int maxi (int a, int b) { return a > b ? a : b; } int maxi (int a, int b) { return a > b ? a : b; }
int absi (int a ) { return a < 0 ? -a : a; } int absi (int a ) { return a < 0 ? -a : a; }

View File

@ -78,6 +78,19 @@ float simplex4( vec4 v ) { return snoise4(v.x,v.y,v.z,v.w); }
float deg (float radians) { return radians / C_PI * 180.0f; } float deg (float radians) { return radians / C_PI * 180.0f; }
float rad (float degrees) { return degrees * C_PI / 180.0f; } float rad (float degrees) { return degrees * C_PI / 180.0f; }
float cycle180 (float angle) {
angle = fmod(angle, 360.0f);
if (angle > 180.0f) angle -= 360.0f;
if (angle < -180.0f) angle += 360.0f;
return angle;
}
float cycle360 (float angle) {
angle = fmod(angle, 360.0f);
if (angle < 0.0f) angle += 360.0f;
return angle;
}
int mini (int a, int b) { return a < b ? a : b; } int mini (int a, int b) { return a < b ? a : b; }
int maxi (int a, int b) { return a > b ? a : b; } int maxi (int a, int b) { return a > b ? a : b; }
int absi (int a ) { return a < 0 ? -a : a; } int absi (int a ) { return a < 0 ? -a : a; }

View File

@ -52,6 +52,9 @@ API float simplex4( vec4 xyzw );
API float deg (float radians); API float deg (float radians);
API float rad (float degrees); API float rad (float degrees);
API float cycle180 (float angle);
API float cycle360 (float angle);
API int mini (int a, int b); API int mini (int a, int b);
API int maxi (int a, int b); API int maxi (int a, int b);
API int absi (int a ); API int absi (int a );

View File

@ -12231,6 +12231,19 @@ float simplex4( vec4 v ) { return snoise4(v.x,v.y,v.z,v.w); }
float deg (float radians) { return radians / C_PI * 180.0f; } float deg (float radians) { return radians / C_PI * 180.0f; }
float rad (float degrees) { return degrees * C_PI / 180.0f; } float rad (float degrees) { return degrees * C_PI / 180.0f; }
float cycle180 (float angle) {
angle = fmod(angle, 360.0f);
if (angle > 180.0f) angle -= 360.0f;
if (angle < -180.0f) angle += 360.0f;
return angle;
}
float cycle360 (float angle) {
angle = fmod(angle, 360.0f);
if (angle < 0.0f) angle += 360.0f;
return angle;
}
int mini (int a, int b) { return a < b ? a : b; } int mini (int a, int b) { return a < b ? a : b; }
int maxi (int a, int b) { return a > b ? a : b; } int maxi (int a, int b) { return a > b ? a : b; }
int absi (int a ) { return a < 0 ? -a : a; } int absi (int a ) { return a < 0 ? -a : a; }

View File

@ -1011,6 +1011,9 @@ API float simplex4( vec4 xyzw );
API float deg (float radians); API float deg (float radians);
API float rad (float degrees); API float rad (float degrees);
API float cycle180 (float angle);
API float cycle360 (float angle);
API int mini (int a, int b); API int mini (int a, int b);
API int maxi (int a, int b); API int maxi (int a, int b);
API int absi (int a ); API int absi (int a );