Last active
August 29, 2015 14:23
-
-
Save mathdoodle/12a2eb7b41502b0a883a to your computer and use it in GitHub Desktop.
Euclidean2 Exponential
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
{ | |
"uuid": "817f8ab0-a47b-4727-aeef-ed8c7d3a06a4", | |
"description": "Euclidean2 Exponential", | |
"dependencies": { | |
"DomReady": "latest", | |
"davinci-mathbox": "latest", | |
"davinci-blade": "1.1.1" | |
}, | |
"operatorOverloading": false | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<style> | |
/* STYLE-MARKER */ | |
</style> | |
<!-- SCRIPTS-MARKER --> | |
</head> | |
<body> | |
<div id="info"></div> | |
<script> | |
// CODE-MARKER | |
</script> | |
</body> | |
</html> |
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
DomReady.ready(function() { | |
ThreeBox.preload([ | |
'../shaders/snippets.glsl.html', | |
], function (assets:{[name:string]:any}) { | |
// MathBox boilerplate | |
var mathbox = mathBox({ | |
cameraControls: true, | |
cursor: true, | |
controlClass: ThreeBox.OrbitControls, | |
elementResize: true, | |
fullscreen: true, | |
screenshot: true, | |
stats: false, | |
scale: 1, | |
}).start(); | |
// Viewport camera/setup | |
var duration = mathbox | |
// Cartesian viewport | |
.viewport({ | |
type: 'cartesian', | |
range: [[-5, 5], [-5, 5], [-5, 5]], | |
scale: [1, 1, 1], | |
polar: 0, | |
}) | |
.camera({ | |
orbit: 4, | |
phi: τ/2, | |
theta: .2, | |
}) | |
.transition(300) | |
// Surface function | |
.surface({ | |
mesh: false, | |
line: true, | |
shaded: true, | |
domain: [[-2.5, 1.5], [-π*1.5, π*1.5]], | |
n: [32, 64], | |
expression: surfaceFunc, | |
}) | |
// Rotate camera continuously | |
mathbox.world().loop().hookPreRender(function () { | |
mathbox.set('camera', { phi: +Date.now() * .0003 }); | |
}); | |
}); | |
}); | |
function surfaceFunc(x: number, y: number): number[] { | |
var m = new blade.Euclidean2(x, 0, 0, y); | |
var expM = m.exp(); | |
return [expM.w, expM.xy, x + Math.sin(Math.PI/2) * y]; | |
} |
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
html, body { height: 100%; } | |
body { margin: 0; padding: 0 } | |
canvas { display: block } | |
#info { | |
position: absolute; | |
left: 50%; | |
bottom: 50px; | |
z-index: 20; | |
width: 300px; | |
margin-left: -150px; | |
padding: 25px; | |
background: rgba(0, 0, 0, .5); | |
color: #fff; | |
font-family: "Lucida Grande", sans-serif; | |
font-size: 16px; | |
text-align: center; | |
border-radius: 3px; | |
text-shadow: 0px 1px 0px rgba(0, 0, 0, .4); | |
opacity: 0; | |
} | |
#info.transition { | |
-webkit-transition: opacity 300ms ease-in-out; | |
-moz-transition: opacity 300ms ease-in-out; | |
transition: opacity 300ms ease-in-out; | |
} | |
#info kbd { | |
background: #aaa; | |
box-shadow: 0px 1px 1px rgba(0, 0, 0, .3); | |
border-radius: 3px; | |
padding: 3px; | |
margin: 3px; | |
font-family: inherit; | |
} | |
.mathbox-label { | |
font-family: 'klavika-web', sans-serif; | |
font-weight: normal; | |
font-style: normal; | |
text-shadow: | |
3px 0px 1px rgb(255, 255, 255), | |
-3px 0px 1px rgb(255, 255, 255), | |
0px -3px 1px rgb(255, 255, 255), | |
0px 3px 1px rgb(255, 255, 255), | |
2px 2px 1px rgb(255, 255, 255), | |
-2px 2px 1px rgb(255, 255, 255), | |
2px -2px 1px rgb(255, 255, 255), | |
-2px -2px 1px rgb(255, 255, 255), | |
3px 2px 1px rgb(255, 255, 255), | |
-3px 2px 1px rgb(255, 255, 255), | |
3px -2px 1px rgb(255, 255, 255), | |
-3px -2px 1px rgb(255, 255, 255), | |
1px 3px 1px rgb(255, 255, 255), | |
-1px 3px 1px rgb(255, 255, 255), | |
1px -3px 1px rgb(255, 255, 255), | |
-1px -3px 1px rgb(255, 255, 255), | |
-1px -1px 1px rgb(255, 255, 255), | |
-1px 1px 1px rgb(255, 255, 255), | |
1px -1px 1px rgb(255, 255, 255), | |
1px 1px 1px rgb(255, 255, 255); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment