Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2012 19:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4163741 to your computer and use it in GitHub Desktop.
Save anonymous/4163741 to your computer and use it in GitHub Desktop.
MathBox API example
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