diff options
[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.html | 17 |
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);
|
