[ Launch: simple trig graphs ] 6804809 by ptvans
-
-
Save ptvans/6804809 to your computer and use it in GitHub Desktop.
simple trig graphs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"simple trig graphs","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"controls":{"function":"sin","x":5.05,"amplitude":5.05,"omega":5.05,"theta":5.05,"phase":5.05},"thumbnail":"http://i.imgur.com/hortXow.png"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var trigfunc = tributary.control({name:"function", options: ["sin", "cos", "tan"]}) | |
//console.log("selected", sel); | |
//simple sin graph | |
//y = a * sin(x + b) | |
//y = amplitude * sin( omega * theta + phase) | |
var x = tributary.control({name:"x", min: 1, max: 10}); | |
trib.amplitude = tributary.control({name:"amplitude", min: 1, max: 10}); | |
trib.omega = tributary.control({name:"omega", min: 1, max: 10}); | |
trib.theta = tributary.control({name:"theta", min: 1, max: 10}); | |
trib.phase = tributary.control({name:"phase", min: 1, max: 10}); | |
var a = 0; | |
var b = 0; | |
var sw = tributary.sw; | |
var sh = tributary.sh; | |
var xmin = -10; | |
var xmax = 300; | |
var ymin = -10; | |
var ymax = 10; | |
var xscale = d3.scale.linear() | |
.domain([xmin, xmax]) | |
.range([0, sw]) | |
var yscale = d3.scale.linear() | |
.domain([ymin, ymax]) | |
.range([0, sh]) | |
function line_maker( data ) { | |
var svgline = d3.svg.line() | |
.x(function(d) { | |
return xscale(d); | |
}) | |
.y(function(d) { | |
var th = trib.theta | |
var ph = trib.phase | |
var y = trib.amplitude * Math.sin( th + ph ); | |
return y | |
}) | |
.interpolate("basis") | |
return svgline(data.data); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment