Summary Files Commits Branches @commit @diff @stats
path: root / Year 2 / Computer Graphics with WebGL / 03-Practice-24.10.2022 / Problem 0302.html
diff options
context:
space:
mode:
Commitac8f5cfaa7a1752e7ba0e62aa40d4bc785e5be34 (patch)
Author
 Syndamia <kamen@syndamia.com>
2022-10-25 18:32:17 +0300
Committer
 Syndamia <kamen@syndamia.com>
2022-10-25 18:32:17 +0300
Filesf5b0b7fb011750eabdc96a9d8266b5931349f599 /Year 2/Computer Graphics with WebGL/03-Practice-24.10.2022/Problem 0302.html
uni-projects-ac8f5cfaa7a1752e7ba0e62aa40d4bc785e5be34.tar
uni-projects-ac8f5cfaa7a1752e7ba0e62aa40d4bc785e5be34.tar.gz
uni-projects-ac8f5cfaa7a1752e7ba0e62aa40d4bc785e5be34.zip
Parenta45f695ebd7b64dfe5cdb911c51d65a5c8eb2cbe (diff)
[WGL/P04] Solved exercises 2-5
1 files changed, 9 insertions, 8 deletions
-rw-r--r--Year 2/Computer Graphics with WebGL/03-Practice-24.10.2022/Problem 0302.html17
diff --git a/Year 2/Computer Graphics with WebGL/03-Practice-24.10.2022/Problem 0302.html b/Year 2/Computer Graphics with WebGL/03-Practice-24.10.2022/Problem 0302.html
index 9d60b02..cffaab6 100644
--- a/Year 2/Computer Graphics with WebGL/03-Practice-24.10.2022/Problem 0302.html
+++ b/Year 2/Computer Graphics with WebGL/03-Practice-24.10.2022/Problem 0302.html
@@ -10,16 +10,16 @@
// отвън се подава само ъгъла
attribute float aAngle;
#define PI 3.14159
- #define TEETH 30.0
- #define RADIUS 0.8
-
+ #define eps 0.0001
+ #define TEETH 35.0
+ #define RADIUS 0.7
+ #define TEETH_DEPTH 0.1
+ #define LEDGE_MODIFIER 2.0
+
void main ()
{
- // тук трябва да се сметне точния радиус
- float r = RADIUS - mod(aAngle, 2.0 * PI / TEETH) * 0.4;
- float angle = aAngle;
- if (r == RADIUS) angle -= 100.0;
- if (angle < 0.0) angle = 0.0; // ugly
+ float r = RADIUS + mod(aAngle, 2.0 * PI / TEETH) / ((360.0 / TEETH - 1.0) * PI / 180.0) * TEETH_DEPTH;;
+ float angle = aAngle - LEDGE_MODIFIER * r;
gl_Position = vec4(r*cos(angle)/1.5,r*sin(angle),0,1);
}
</script>
@@ -52,6 +52,7 @@
var data = [ ];
for(var i=0; i<n; i++)
data.push(2*Math.PI*i/n);
+ console.log(data);
var buf = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER,buf);