Created
November 28, 2012 19:57
-
-
Save anonymous/4163741 to your computer and use it in GitHub Desktop.
MathBox API example
This file contains hidden or 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
Open this page and open the JavaScript console / inspector: | |
http://acko.net/files/mathbox/MathBox.js/examples/ComplexExponentiation.html | |
Paste in these commands to manipulate the scene: | |
console.log(mathbox.select('surface')); // Surface primitives | |
console.log(mathbox.select('surface')[0].get()); // Get attributes of first surface | |
mathbox.set('surface', { color: 0x30a030 }); // Change color of surface(s) | |
// Move camera and expand surface / viewport | |
mathbox.animate('camera', { theta: 1 }, { duration: 2000 }); | |
mathbox.animate('surface', { color: 0x700000, 'domain': [[-2.5, 1.5], [-10, 10]] }, { duration: 3000 }); | |
mathbox.animate('viewport', { range: [[-5, 5], [-5, 5], [-10, 10]] }, { duration: 3000 }); | |
// Morph into something else | |
mathbox.animate('surface', { expression: function (x, y) { | |
var p = π/2; | |
var z = -Math.exp(x) + 5; | |
return [ | |
Math.cos(y) * z + Math.cos(p) * y, | |
Math.sin(y) * z, | |
x + Math.sin(p) * y | |
]; | |
} }, { duration: 4000 }); | |
(See github.com/unconed/MathBox.js for partial docs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment