diff --git a/README.md b/README.md index 7672478..0c5f542 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ npm i git://github.com/ykob/glsl-util.git ``` ## convertHsvToRgb and convertRgbToHsv -this is the function that convetts RGB to HSV. or is its opposite. + +this function converts RGB to HSV. or is its opposite. ### Quote source @@ -29,3 +30,14 @@ http://lolengine.net/blog/2013/07/27/rgb-to-hsv-in-glsl ``` #pragma glslify: random = require(glsl-util/random); ``` + +## polar + +this function calculates polar coordinates. + +### usage + +``` +#pragma glslify: polar = require(glsl-util/polar); +vec3 p = polar(float radian1, float radian2, float radius); +``` diff --git a/polar.glsl b/polar.glsl new file mode 100644 index 0000000..d394cac --- /dev/null +++ b/polar.glsl @@ -0,0 +1,8 @@ +vec3 polar(float radian1, float radian2, float radius) { + return vec3( + cos(radian1) * cos(radian2) * radius, + sin(radian1) * radius, + cos(radian1) * sin(radian2) * radius, + ) +} +#pragma glslify: export(polar)