{"id":3346,"date":"2017-10-02T02:54:43","date_gmt":"2017-10-02T00:54:43","guid":{"rendered":"http:\/\/hintz.bplaced.net\/en\/?p=3346"},"modified":"2017-10-02T02:54:43","modified_gmt":"2017-10-02T00:54:43","slug":"deglattes-newton-fraktalensmooth-newton-fractal","status":"publish","type":"post","link":"http:\/\/hintz.bplaced.net\/de\/2017\/webgl\/smooth-newton-fractal\/","title":{"rendered":"Glattes Newton Fraktal"},"content":{"rendered":"<p><\/p>\n<p class=\"webgl\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/hintz.bplaced.net\/images\/2017\/10\/SmoothNewtonFractal.jpg\" width=\"620\" height=\"620\" \/><a href=\"http:\/\/glslsandbox.com\/e#42786.3\"><canvas width=\"620\" height=\"620\"><script type=\"x-shader\/x-vertex\">attribute vec2 position; void main() { gl_Position = vec4(position, 0, 1); }<\/script><script type=\"x-shader\/x-fragment\">\n#ifdef GL_ES\nprecision mediump float;\n#endif\n\/\/ Smooth Newton Fractal 1-z^3 by @hintz\n\/\/ v2 HSV2RGB changed\n\/\/ v3 added smooth iteration value, which is needed for future 3D conversion. 2017-10-02 @hintz\nuniform float time;\nuniform vec2 mouse;\nuniform vec2 resolution;\nfloat deltax = 12.0 + sin(time*0.4) * 10.0;\nfloat deltay = resolution.y \/ resolution.x * deltax;\nfloat theta = time*0.1;\nfloat cosThetaPi = cos(theta);\nfloat sinThetaPi = sin(theta);\n\/\/ for pretty colors: Hue-Saturation-Value to Red-Green-Blue\nvec4 hsvToRgb(vec3 hsv) \n{\n\tvec3 rgb = ((clamp(abs(fract(hsv.x +vec3(0.,2.\/3.,1.\/3.))*2.-1.)*3.-1.,0.,1.)-1.)*hsv.y+1.)*hsv.z; \n\treturn vec4 (rgb,1.0);\n}\n\/\/ complex number multiplication: a * b\nvec2 mul(vec2 a, vec2 b)\n{\n\treturn vec2(a.x*b.x - a.y*b.y, a.y*b.x + a.x*b.y);\n}\n\/\/ complex number division: a \/ b \nvec2 div(vec2 a, vec2 b)\n{\n\treturn vec2((a.x*b.x + a.y*b.y) \/ (b.x*b.x + b.y*b.y), (a.y*b.x - a.x*b.y) \/ (b.x*b.x + b.y*b.y));\n}\n\/\/     1 - z^3\n\/\/ z - -------\n\/\/     3 * z^2\nvec2 znext(vec2 z)       \n{                        \n\tvec2 z2 = mul(z,z);    \n\treturn z - div(vec2(1.0,0.0)+mul(z2,z),3.0*z2);\n}\nvec2 newtonfractal(vec2 z)\n{\n\tfor (int n=0; n<1000; n++)\n\t{\n\t\tvec2 old = z;\n\t\tz = znext(z);\n\t    \tfloat d = length(z - old);\t\n\t    \tif (d < 0.01)\n\t    \t{\n\t\t\tfloat u = float(n) + log2(log(0.01)\/log(d));\n\t\t\treturn vec2(z.x + z.y + time*0.1, u*0.03);\n\t\t}\n\t}\n\treturn z;\n}\nvoid main(void)\n{\n  float real = deltax * (gl_FragCoord.x \/ resolution.x - 0.5);\n  float imag = deltay * (gl_FragCoord.y \/ resolution.y - 0.5);\n  float realR = real*cosThetaPi - imag*sinThetaPi;\n  float imagR = real*sinThetaPi + imag*cosThetaPi;\t\n  vec2 results = newtonfractal(vec2(realR, imagR));\n  vec3 hsv = vec3(results.x + results.y, 0.8, 1.0 - results.y);\t\n  gl_FragColor = hsvToRgb(hsv);\n}\n<\/script><\/canvas><\/a><\/p>\n<p>Normalerweise wird die Farbe bei Fraktalen aus der Anzahl der Iterationen bestimmt, die berechnet wurden, bevor die Abbruchbedingung ist. Wenn man jedoch den Abstand der letzten beiden Rechenergebnisse mit einbezieht, l\u00e4sst sich die Anzahl mit Nachkommastellen angeben und daraus eine gleichm\u00e4\u00dfige F\u00e4rbung erzielen.<\/p>","protected":false},"excerpt":{"rendered":"<p>Normalerweise wird die Farbe bei Fraktalen aus der Anzahl der Iterationen bestimmt, die berechnet wurden, bevor die Abbruchbedingung ist. Wenn man jedoch den Abstand der letzten beiden Rechenergebnisse mit einbezieht, l\u00e4sst sich die Anzahl mit Nachkommastellen angeben und daraus eine gleichm\u00e4\u00dfige F\u00e4rbung erzielen.<\/p>\n","protected":false},"author":1,"featured_media":3349,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[144],"tags":[151,147,150,145,122,189],"_links":{"self":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3346"}],"collection":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/comments?post=3346"}],"version-history":[{"count":4,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3346\/revisions"}],"predecessor-version":[{"id":3351,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3346\/revisions\/3351"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media\/3349"}],"wp:attachment":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media?parent=3346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/categories?post=3346"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/tags?post=3346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}