{"id":3031,"date":"2013-05-06T16:36:46","date_gmt":"2013-05-06T14:36:46","guid":{"rendered":"http:\/\/hintz.bplaced.net\/?p=3031"},"modified":"2017-03-21T19:49:42","modified_gmt":"2017-03-21T18:49:42","slug":"newton","status":"publish","type":"post","link":"http:\/\/hintz.bplaced.net\/de\/2013\/webgl\/newton-fraktal-1-z%c2%b3\/","title":{"rendered":"Newton Fraktal 1-z\u00b3"},"content":{"rendered":"<p>Dies ist eine Darstellung des Newton Fraktals 1-z\u00b3.<\/p>\n<p class=\"webgl\"><img decoding=\"async\" src=\"http:\/\/hintz.bplaced.net\/images\/2013\/05\/newton.jpg\" \/><a href=\"http:\/\/glslsandbox.com\/e#39347.1\"><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\/\/ Newtow Fractal 1-z^3 with abs() by @hintz\n#ifdef GL_ES\nprecision mediump float;\n#endif\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\nvec4 hsv2rgb(vec3 col)\n{\n    float iH = floor(mod(col.x,1.0)*6.0);\n    float fH = mod(col.x,1.0)*6.0-iH;\n    float p = col.z*(1.0-col.y);\n    float q = col.z*(1.0-fH*col.y);\n    float t = col.z*(1.0-(1.0-fH)*col.y);\n  if (iH==0.0)\n  {\n    return vec4(col.z, t, p, 1.0);\n  }\n  if (iH==1.0)\n  {\n    return vec4(q, col.z, p, 1.0);\n  }\n  if (iH==2.0)\n  {\n    return vec4(p, col.z, t, 1.0);\n  }\n  if (iH==3.0)\n  {\n    return vec4(p, q, col.z, 1.0);\n  }\n  if (iH==4.0)\n  {\n    return vec4(t, p, col.z, 1.0);\n  } \n  return vec4(col.z, p, q, 1.0); \n}\n\/\/ complex number math functions\nvec2 mul(vec2 a, vec2 b)\n{\n  return vec2(a.x*b.x - a.y*b.y, a.y*b.x + a.x*b.y);\n}\nvec2 div(vec2 a, vec2 b)\n{\n  return 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}\nvec2 znext(vec2 z)\n{\n  vec2 z2=mul(z,z);\n  return z-div(vec2(1.0,0.0)-mul(z2,z), -3.0*z2);\n}\nvec2 newtonfractal(vec2 z)\n{\n  for (int n=0;n<100;n++)\n  {\n    vec2 old=z;\n    z = znext(z);\n    vec2 d=z-old;\n    \/\/d*=d;\n    d=abs(d); \n    if (d.x+d.y < 0.3)\n    {\n      return vec2(z.x+z.y+time*0.1, float(n)*0.06);\n    }\n  } \n    \/\/(float(n) + (0.32663426-log(log(sqrt(z.x * z.x + z.y * z.y))))\/0.693147181)\/float(iterations)\n    \/\/float(n)\/float(iterations)\n  return 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;\n  vec2 results = newtonfractal(vec2(realR, imagR));\n  float h = results.x;\n  float v = 1.0-results.y;\n  float s = 0.8;\n  gl_FragColor = hsv2rgb(vec3(h, s, v));\n}\n<\/script><\/canvas><\/a><\/p>\n<p><\/p>","protected":false},"excerpt":{"rendered":"<p>Dies ist eine Darstellung des Newton Fraktals 1-z\u00b3.<\/p>\n","protected":false},"author":1,"featured_media":3036,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[144],"tags":[149,151,152,189],"_links":{"self":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3031"}],"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=3031"}],"version-history":[{"count":14,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3031\/revisions"}],"predecessor-version":[{"id":3259,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/posts\/3031\/revisions\/3259"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media\/3036"}],"wp:attachment":[{"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/media?parent=3031"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/categories?post=3031"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/hintz.bplaced.net\/de\/wp-json\/wp\/v2\/tags?post=3031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}