fuckingtech/public/assets/glsl/lygia/space/rotateZ.msl
Elias Rhouzlane bf76c6b086 fix: code
2025-04-06 17:23:52 +02:00

39 lines
1 KiB
Text

#include "../math/rotate4dZ.msl"
/*
contributors: Patricio Gonzalez Vivo
description: rotate a 2D space by a radian angle
use: rotateZ(<float3|float4> pos, float radian [, float3 center])
options:
- CENTER_3D
license:
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
*/
#ifndef FNC_ROTATEZ
#define FNC_ROTATEZ
float4 rotateZ(float4 v, float r, float4 c) {
return rotate4dZ(r) * (v - c) + c;
}
float4 rotateZ(float4 v, float r) {
#ifdef CENTER_4D
return rotate4dZ(r) * (v - CENTER_3D) + CENTER_3D;
#else
return rotate4dZ(r) * v;
#endif
}
float3 rotateZ(float3 v, float r, float3 c) {
return (rotate4dZ(r) * float4(v - c, 0.0) ).xyz + c;
}
float3 rotateZ(float3 v, float r) {
#ifdef CENTER_3D
return (rotate4dZ(r) * float4(v - CENTER_3D, 0.0)).xyz + CENTER_3D;
#else
return (rotate4dZ(r) * float4(v, 0.0)).xyz;
#endif
}
#endif