From 8863f97e4c85180fc0ae09e563febf5a2d9ef84c Mon Sep 17 00:00:00 2001 From: yoichi kobayashi Date: Thu, 26 Jan 2017 14:44:10 +0900 Subject: [PATCH] [add] polar function. this function calculates polar coordinates. --- README.md | 14 +++++++++++++- polar.glsl | 8 ++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 polar.glsl 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)