Jason (jcreed) wrote,
Jason
jcreed

Made some dutch baby that turned out real good. K tried some of the caramel sauce on it.

Puttered around with base64 encodings of small images for the purpose of some nebulously as-yet-not-very-completely-designed language game, and separately trying to figure out a plausible way to achieve the "to ensure these functions are perfectly and mathematically derivable/smooth one would need to window the distance decaying function with a smoothstep or something" from http://iquilezles.org/www/articles/smoothvoronoi/smoothvoronoi.htm.

I tried, among other things, copy-pasting the code
THRESH = 0.5;

pts = [{x:0.1, y:0.9}, {x:0.5,y:-0.5}, {x:-0.3,y:-0.8}];
function foo(x, y) {
  var ds = pts.map(function(pt, ix) {
    var v = {x: pt.x - x, y:pt.y - y};
    return Math.sqrt( v.x * v.x + v.y * v.y);
  });
  ds.sort(function(a, b) { return a-b });
  var weights = [];
  var total_weight = 0;
  for (var i = 0; i < ds.length; i++) {
    var t = (ds[i] - ds[0]) / THRESH;
    if (t > 1) 
      break;
    else {
      var weight = 1 - 3 * t * t + 2 * t * t * t;
      weights.push(weight);
      total_weight += weight;
    }
  }
  var rv = 0;
  weights.forEach(function(w, ix) {
    rv += w * Math.exp(-ds[ix]);
  });

  return -Math.log(rv);
}

into the browser dev console while at https://developer.cdn.mozilla.net/media/uploads/demos/g/u/guska076/fa5058c56d868f08311aedaae32536cf/3d-grapher-with-full_1354293417_demo_package/index.html and graphing foo(x, y) but it has awful, awful creases around the voronoi cell boundaries so I know I'm doing something wrong.
Tags: math
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments