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

21 lines
No EOL
452 B
Text

/*
contributors: [Ivan Dianov, Kathy McGuiness]
description: cartesian to polar transformation.
use: <float2|float3> cart2polar(<float2|float3> st)
*/
#ifndef FNC_CART2POLAR
#define FNC_CART2POLAR
float2 cart2polar(float2 st) {
return float2(atan2(st.y, st.x), length(st));
}
float3 cart2polar( float3 st ) {
float r = length(st);
float theta = acos(st.z/r);
float phi = atan2(st.y, st.x);
return float3(r, theta, phi);
}
#endif