Skip to content

Instantly share code, notes, and snippets.

@KKostya
KKostya / index.html
Last active December 19, 2015 20:48
Proof of principle: z^2 conformal map with d3js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.line { fill: none; stroke: steelblue; stroke-width: 1.5px; }
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function Complex(re, im) { this.re = re; this.im = im; };
Complex.prototype.clone = function() { return new Complex(this.re,this.im); };
@KKostya
KKostya / index.html
Created July 16, 2013 22:18
Joukowsky transform in d3.js
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.line { fill: none; stroke: steelblue; stroke-width: 1.5px; }
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function Complex(re, im) { this.re = re; this.im = im; };
Complex.prototype.clone = function(){ return new Complex(this.re,this.im); };
@KKostya
KKostya / index.html
Created July 17, 2013 14:18
Animated Joukowski map
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.ani .line { fill: none; stroke: steelblue; stroke-width: 1.5px; }
.grd .line { fill: none; stroke: black; stroke-width: 0.5px; }
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
function Complex(re, im) { this.re = re; this.im = im; };
@KKostya
KKostya / index.html
Last active December 19, 2015 22:08
Z^2 + brush
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg { font: 10px sans-serif; }
.brsh .extent { fill: steelblue; stroke: grey; stroke-width: 0.5px; fill-opacity: .125;}
.brsh .back { fill: none; stroke: black; stroke-width: 1px;}
.mapd .line { fill: none; stroke: black; stroke-width: 1px; }
.axis { fill: none; stroke: black; }
</style>
<body>
@KKostya
KKostya / index.html
Created July 17, 2013 22:57
Joukowski + d3.brush
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg { font: 10px sans-serif; }
.brsh .extent { fill: steelblue; stroke: grey; stroke-width: 0.5px; fill-opacity: .125;}
.brsh .back { fill: none; stroke: black; stroke-width: 1px;}
.line { fill: none; stroke: black; stroke-width: 0.5px; }
.axis { fill: none; stroke: black; }
</style>
<body>
@KKostya
KKostya / index.html
Last active December 20, 2015 00:18
Take on resampling.
<!DOCTYPE html>
<meta charset="utf-8">
<style>
svg { font: 10px sans-serif; }
.brsh .extent { fill: steelblue; stroke: grey; stroke-width: 0.5px; fill-opacity: .125;}
.brsh .back { fill: none; stroke: black; stroke-width: 1px;}
.line { fill: none; stroke: black; stroke-width: 1px; }
.axis { fill: none; stroke: black; }
</style>
<body>
@KKostya
KKostya / confmap.js
Last active December 20, 2015 03:49
More fun with Joukowski
function dist(z0,z,z1)
{
var dx10 = z1.re-z0.re, dy10 = z1.im-z0.im;
var dx0 = z.re-z0.re, dy0 = z.im-z0.im;
return Math.pow(dx10*dy0-dy10*dx0,2)/(dx0*dx0+dy0*dy0);
}
function resampleLoop(f,ps,eps)
{
var ds = ps.map(f);
@KKostya
KKostya / confmap.js
Created July 24, 2013 22:19
Circle-to-circle map
function dist(z0,z,z1)
{
var dx10 = z1.re-z0.re, dy10 = z1.im-z0.im;
var dx0 = z.re-z0.re, dy0 = z.im-z0.im;
return Math.pow(dx10*dy0-dy10*dx0,2)/(dx0*dx0+dy0*dy0);
}
function resampleLoop(f,ps,eps)
{
var ds = ps.map(f);
@KKostya
KKostya / Slider.js
Created September 12, 2013 16:58
Reusable slider
function slider()
{
var margin = {top: 5, left: 15, right: 10, bottom: 5},
width = 300 - margin.left - margin.right,
height = 40 - margin.top - margin.bottom,
brush = d3.svg.brush(),
handle, slider,
value = 0,
upd = function(d){value = d;},
cback = function(d){};
@KKostya
KKostya / Slider.js
Last active August 29, 2015 13:56
Lienard -- Wiechert
function slider(dom)
{
var margin = {top: 5, left: 15, right: 10, bottom: 5},
width = 300 - margin.left - margin.right,
height = 40 - margin.top - margin.bottom,
brush = d3.svg.brush(),
handle, slider,
value = 0,
upd = function(d){value = d;},
cback = function(d){};