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

22 lines
No EOL
527 B
GLSL

/*
contributors: [Ivan Dianov, Shadi El Hajj]
description: polar to cartesian conversion.
use: polar2cart(<vec2> polar)
*/
#ifndef FNC_POLAR2CART
#define FNC_POLAR2CART
vec2 polar2cart(in vec2 polar) {
return vec2(cos(polar.x), sin(polar.x)) * polar.y;
}
// https://mathworld.wolfram.com/SphericalCoordinates.html
vec3 polar2cart( in float r, in float phi, in float theta) {
float x = r * cos(theta) * sin(phi);
float y = r * sin(theta) * sin(phi);
float z = r * cos(phi);
return vec3(x, y, z);
}
#endif