Steenbrink/DeformacionGenerica0.ipynb

1861 lines
100 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "72d5a30c-1a59-4a55-9680-fdfa7979625b",
"metadata": {},
"outputs": [],
"source": [
"# load('zetas_triples_general.py')\n",
"R.<x, y, z> = PolynomialRing(QQ, order='neglex')\n",
"S.<u, v> = PolynomialRing(QQ, order='neglex')\n",
"f = v^2 - u^2\n",
"g = u^4\n",
"F = z^3 - 3 * f(u=x, v=y) * z + 2 * g(u=x, v=y)\n",
"h = F.discriminant(z)(x=u, y=v)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "57f4e587-fd6a-4aa2-8423-78e8b5f0d2dd",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"F.jacobian_ideal().vector_space_dimension()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "9207fe2e-adca-4549-a083-74d467563684",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"R0.<t> = QQ[]\n",
"Kt = R0.fraction_field()\n",
"Rt.<x, y, z> = PolynomialRing(Kt, order='neglex')\n",
"S.<u, v> = PolynomialRing(Kt, order='neglex')\n",
"f = v^2 - u^2\n",
"g = u^4\n",
"F = z^3 - 3 * f(u=x, v=y) * z + 2 * g(u=x, v=y)\n",
"h = F.discriminant(z)(x=u, y=v)\n",
"F.jacobian_ideal().vector_space_dimension()"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "27e92ddc-34d6-4290-880f-9d3561a8ec4e",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"10"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Ft = F + t * x * z^2\n",
"Ft.jacobian_ideal().vector_space_dimension()"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "8cc358aa-03d1-4b9c-b4ff-87b0324bd55b",
"metadata": {},
"outputs": [],
"source": [
"load('zetas_triples_general.py')\n",
"ht = Ft.discriminant(z)(x=u, y=v)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "d21a93b0-b0c4-4cd2-b648-f4bca8f78376",
"metadata": {},
"outputs": [],
"source": [
"Zt = ZetaFunctions(ht)\n",
"Z = ZetaFunctions(h)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "59240908-d672-4520-90e5-7358840f8c23",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(-108) * (-v + u)^3 * (v + u)^3]"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[p.factor() for p in Z.get_polyfaces_dictionary(compact=True) if p.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "a1a4111c-050d-4656-be38-ceac87684b47",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(9) * (v - u)^2 * (v + u)^2 * (12*v^2 + (t^2 - 12)*u^2)]"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[p.factor() for p in Zt.get_polyfaces_dictionary(compact=True) if p.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "8ac2847d-121a-4a78-a202-7e1692998c99",
"metadata": {},
"outputs": [],
"source": [
"Zta = ZetaFunctions(ht(v=v + u))\n",
"Za = ZetaFunctions(h(v=v + u))"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "e7884c6b-458b-4d7c-8c8f-376ec4b87c9a",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(108) * v^3 * (v + 2*u)^3, (108) * u^3 * (8*v^3 - u^5)]"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[p.factor() for p in Za.get_polyfaces_dictionary(compact=True) if p.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "442b2c9c-c7f1-4fb9-ac12-bf372d90a342",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(9) * v^2 * (v + 2*u)^2 * (12*v^2 + 24*u*v + (t^2)*u^2),\n",
" ((4*t^2)) * u^4 * (9*v^2 + (-2*t)*u^3)]"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[p.factor() for p in Zta.get_polyfaces_dictionary(compact=True) if p.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "bb3b178d-c56c-491d-8bc6-c951d101ff92",
"metadata": {},
"outputs": [],
"source": [
"Ztb = ZetaFunctions(ht(v=v - u))\n",
"Zb = ZetaFunctions(h(v=v -u ))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "7121f34f-2792-4ed5-8e20-fb0024e1638d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(-108) * (-v + 2*u)^3 * v^3, (-108) * u^3 * (8*v^3 + u^5)]"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[p.factor() for p in Zb.get_polyfaces_dictionary(compact=True) if p.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "9986d1b9-fc85-4019-845f-438f79021f2b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(9) * v^2 * (v - 2*u)^2 * (12*v^2 - 24*u*v + (t^2)*u^2),\n",
" ((4*t^2)) * u^4 * (9*v^2 + (-2*t)*u^3)]"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"[p.factor() for p in Ztb.get_polyfaces_dictionary(compact=True) if p.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 24,
"id": "fb974d4e-ea53-48e8-97e3-6878039dfbe6",
"metadata": {},
"outputs": [],
"source": [
"Zt = ZetaFunctions(Ft)\n",
"Z = ZetaFunctions(F)"
]
},
{
"cell_type": "code",
"execution_count": 47,
"id": "9974eefe-db38-4da1-b438-eb56f6effbe4",
"metadata": {},
"outputs": [],
"source": [
"def nwt(p):\n",
" return p(u=u^2, v=u^7 * (v + 1))"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "2b0713c1-0f81-4477-b0e4-b37c3ad80456",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
"&lt;html&gt;\n",
"&lt;head&gt;\n",
"&lt;title&gt;&lt;/title&gt;\n",
"&lt;meta charset=&quot;utf-8&quot;&gt;\n",
"&lt;meta name=viewport content=&quot;width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0&quot;&gt;\n",
"&lt;style&gt;\n",
"\n",
" body { margin: 0px; overflow: hidden; }\n",
"\n",
" #menu-container { position: absolute; bottom: 30px; right: 40px; cursor: default; }\n",
"\n",
" #menu-message { position: absolute; bottom: 0px; right: 0px; white-space: nowrap;\n",
" display: none; background-color: #F5F5F5; padding: 10px; }\n",
"\n",
" #menu-content { position: absolute; bottom: 0px; right: 0px;\n",
" display: none; background-color: #F5F5F5; border-bottom: 1px solid black;\n",
" border-right: 1px solid black; border-left: 1px solid black; }\n",
"\n",
" #menu-content div { border-top: 1px solid black; padding: 10px; white-space: nowrap; }\n",
"\n",
" #menu-content div:hover { background-color: #FEFEFE; }\n",
"\n",
" .dark-theme #menu-container { color: white; }\n",
"\n",
" .dark-theme #menu-message { background-color: #181818; }\n",
"\n",
" .dark-theme #menu-content { background-color: #181818; border-color: white; }\n",
"\n",
" .dark-theme #menu-content div { border-color: white; }\n",
"\n",
" .dark-theme #menu-content div:hover { background-color: #303030; }\n",
"\n",
"&lt;/style&gt;\n",
"\n",
"&lt;/head&gt;\n",
"\n",
"&lt;body&gt;\n",
"\n",
"&lt;script src=&quot;/nbextensions/threejs-sage/r122/three.min.js&quot;&gt;&lt;/script&gt;\n",
"&lt;script&gt;\n",
" if ( !window.THREE ) document.write(&#x27; \\\n",
"&lt;script src=&quot;https://cdn.jsdelivr.net/gh/sagemath/threejs-sage@r122/build/three.min.js&quot;&gt;&lt;\\/script&gt; \\\n",
" &#x27;);\n",
"&lt;/script&gt;\n",
" \n",
"&lt;script&gt;\n",
"\n",
" var options = {&quot;animate&quot;: false, &quot;animationControls&quot;: true, &quot;aspectRatio&quot;: [1.0, 1.0, 1.0], &quot;autoScaling&quot;: [false, false, false], &quot;autoPlay&quot;: true, &quot;axes&quot;: false, &quot;axesLabels&quot;: [&quot;x&quot;, &quot;y&quot;, &quot;z&quot;], &quot;axesLabelsStyle&quot;: null, &quot;decimals&quot;: 2, &quot;delay&quot;: 20, &quot;frame&quot;: true, &quot;loop&quot;: true, &quot;projection&quot;: &quot;perspective&quot;, &quot;theme&quot;: &quot;light&quot;, &quot;viewpoint&quot;: false};\n",
" var animate = options.animate;\n",
"\n",
" if ( options.theme === &#x27;dark&#x27; )\n",
" document.body.className = &#x27;dark-theme&#x27;;\n",
"\n",
" var scene = new THREE.Scene();\n",
"\n",
" var renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer: true } );\n",
" renderer.setPixelRatio( window.devicePixelRatio );\n",
" renderer.setSize( window.innerWidth, window.innerHeight );\n",
" renderer.setClearColor( options.theme === &#x27;dark&#x27; ? 0 : 0xffffff, 1 );\n",
" document.body.appendChild( renderer.domElement );\n",
"\n",
" var b = [{&quot;x&quot;:-0.05706339097770922, &quot;y&quot;:-0.048541019662496854, &quot;z&quot;:-0.05999999999999995}, {&quot;x&quot;:5.0, &quot;y&quot;:3.0, &quot;z&quot;:4.0}]; // bounds\n",
"\n",
" if ( b[0].x === b[1].x ) {\n",
" b[0].x -= 1;\n",
" b[1].x += 1;\n",
" }\n",
" if ( b[0].y === b[1].y ) {\n",
" b[0].y -= 1;\n",
" b[1].y += 1;\n",
" }\n",
" if ( b[0].z === b[1].z ) {\n",
" b[0].z -= 1;\n",
" b[1].z += 1;\n",
" }\n",
"\n",
" var rxRange = Math.sqrt( Math.pow( b[1].z - b[0].z, 2 )\n",
" + Math.pow( b[1].y - b[0].y, 2 ) );\n",
" var ryRange = Math.sqrt( Math.pow( b[1].x - b[0].x, 2 )\n",
" + Math.pow( b[1].z - b[0].z, 2 ) );\n",
" var rzRange = Math.sqrt( Math.pow( b[1].x - b[0].x, 2 )\n",
" + Math.pow( b[1].y - b[0].y, 2 ) );\n",
" var xRange = b[1].x - b[0].x;\n",
" var yRange = b[1].y - b[0].y;\n",
" var zRange = b[1].z - b[0].z;\n",
"\n",
" var ar = options.aspectRatio;\n",
" var a = [ ar[0], ar[1], ar[2] ]; // aspect multipliers\n",
"\n",
" var autoScaling = options.autoScaling;\n",
" var autoAspect = 2.5;\n",
" if ( xRange &gt; autoAspect * rxRange &amp;&amp; autoScaling[0] ) a[0] = autoAspect * rxRange / xRange;\n",
" if ( yRange &gt; autoAspect * ryRange &amp;&amp; autoScaling[1] ) a[1] = autoAspect * ryRange / yRange;\n",
" if ( zRange &gt; autoAspect * rzRange &amp;&amp; autoScaling[2] ) a[2] = autoAspect * rzRange / zRange;\n",
"\n",
" // Distance from (xMid,yMid,zMid) to any corner of the bounding box, after applying aspectRatio\n",
" var midToCorner = Math.sqrt( a[0]*a[0]*xRange*xRange + a[1]*a[1]*yRange*yRange + a[2]*a[2]*zRange*zRange ) / 2;\n",
"\n",
" var xMid = ( b[0].x + b[1].x ) / 2;\n",
" var yMid = ( b[0].y + b[1].y ) / 2;\n",
" var zMid = ( b[0].z + b[1].z ) / 2;\n",
"\n",
" var box = new THREE.Geometry();\n",
" box.vertices.push( new THREE.Vector3( a[0]*b[0].x, a[1]*b[0].y, a[2]*b[0].z ) );\n",
" box.vertices.push( new THREE.Vector3( a[0]*b[1].x, a[1]*b[1].y, a[2]*b[1].z ) );\n",
" var boxMesh = new THREE.Line( box );\n",
" var boxColor = options.theme === &#x27;dark&#x27; ? &#x27;white&#x27; : &#x27;black&#x27;;\n",
" if ( options.frame ) scene.add( new THREE.BoxHelper( boxMesh, boxColor ) );\n",
"\n",
" if ( options.axesLabels ) {\n",
"\n",
" var d = options.decimals; // decimals\n",
" var offsetRatio = 0.1;\n",
" var al = options.axesLabels;\n",
" var als = options.axesLabelsStyle || [{}, {}, {}];\n",
"\n",
" var offset = offsetRatio * a[1]*( b[1].y - b[0].y );\n",
" var xm = xMid.toFixed(d);\n",
" if ( /^-0.?0*$/.test(xm) ) xm = xm.substr(1);\n",
" addLabel( al[0] + &#x27;=&#x27; + xm, a[0]*xMid, a[1]*b[1].y+offset, a[2]*b[0].z, als[0] );\n",
" addLabel( ( b[0].x ).toFixed(d), a[0]*b[0].x, a[1]*b[1].y+offset, a[2]*b[0].z, als[0] );\n",
" addLabel( ( b[1].x ).toFixed(d), a[0]*b[1].x, a[1]*b[1].y+offset, a[2]*b[0].z, als[0] );\n",
"\n",
" var offset = offsetRatio * a[0]*( b[1].x - b[0].x );\n",
" var ym = yMid.toFixed(d);\n",
" if ( /^-0.?0*$/.test(ym) ) ym = ym.substr(1);\n",
" addLabel( al[1] + &#x27;=&#x27; + ym, a[0]*b[1].x+offset, a[1]*yMid, a[2]*b[0].z, als[1] );\n",
" addLabel( ( b[0].y ).toFixed(d), a[0]*b[1].x+offset, a[1]*b[0].y, a[2]*b[0].z, als[1] );\n",
" addLabel( ( b[1].y ).toFixed(d), a[0]*b[1].x+offset, a[1]*b[1].y, a[2]*b[0].z, als[1] );\n",
"\n",
" var offset = offsetRatio * a[1]*( b[1].y - b[0].y );\n",
" var zm = zMid.toFixed(d);\n",
" if ( /^-0.?0*$/.test(zm) ) zm = zm.substr(1);\n",
" addLabel( al[2] + &#x27;=&#x27; + zm, a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*zMid, als[2] );\n",
" addLabel( ( b[0].z ).toFixed(d), a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*b[0].z, als[2] );\n",
" addLabel( ( b[1].z ).toFixed(d), a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*b[1].z, als[2] );\n",
"\n",
" }\n",
"\n",
" function addLabel( text, x, y, z, style ) {\n",
"\n",
" var color = style.color || &#x27;black&#x27;;\n",
" var fontSize = style.fontSize || 14;\n",
" var fontFamily = style.fontFamily || &#x27;monospace&#x27;;\n",
" var fontStyle = style.fontStyle || &#x27;normal&#x27;;\n",
" var fontWeight = style.fontWeight || &#x27;normal&#x27;;\n",
" var opacity = style.opacity || 1;\n",
"\n",
" if ( options.theme === &#x27;dark&#x27; )\n",
" if ( color === &#x27;black&#x27; || color === &#x27;#000000&#x27; )\n",
" color = &#x27;white&#x27;;\n",
"\n",
" if ( Array.isArray( fontStyle ) ) {\n",
" fontFamily = fontFamily.map( function( f ) {\n",
" // Need to put quotes around fonts that have whitespace in their names.\n",
" return /\\s/.test( f ) ? &#x27;&quot;&#x27; + f + &#x27;&quot;&#x27; : f;\n",
" }).join(&#x27;, &#x27;);\n",
" }\n",
"\n",
" var canvas = document.createElement( &#x27;canvas&#x27; );\n",
" var context = canvas.getContext( &#x27;2d&#x27; );\n",
" var pixelRatio = Math.round( window.devicePixelRatio );\n",
"\n",
" // For example: italic bold 20px &quot;Times New Roman&quot;, Georgia, serif\n",
" var font = [fontStyle, fontWeight, fontSize + &#x27;px&#x27;, fontFamily].join(&#x27; &#x27;);\n",
"\n",
" context.font = font;\n",
" var width = context.measureText( text ).width;\n",
" var height = fontSize;\n",
"\n",
" // The dimensions of the canvas&#x27;s underlying image data need to be powers\n",
" // of two in order for the resulting texture to support mipmapping.\n",
" canvas.width = THREE.MathUtils.ceilPowerOfTwo( width * pixelRatio );\n",
" canvas.height = THREE.MathUtils.ceilPowerOfTwo( height * pixelRatio );\n",
"\n",
" // Re-compute the unscaled dimensions after the power of two conversion.\n",
" width = canvas.width / pixelRatio;\n",
" height = canvas.height / pixelRatio;\n",
"\n",
" canvas.style.width = width + &#x27;px&#x27;;\n",
" canvas.style.height = height + &#x27;px&#x27;;\n",
"\n",
" context.scale( pixelRatio, pixelRatio );\n",
" context.fillStyle = color;\n",
" context.font = font; // Must be set again after measureText.\n",
" context.textAlign = &#x27;center&#x27;;\n",
" context.textBaseline = &#x27;middle&#x27;;\n",
" context.fillText( text, width/2, height/2 );\n",
"\n",
" var texture = new THREE.Texture( canvas );\n",
" texture.needsUpdate = true;\n",
"\n",
" var materialOptions = { map: texture, sizeAttenuation: false, depthWrite: false };\n",
" if ( opacity &lt; 1 ) {\n",
" // Setting opacity=1 would cause the texture&#x27;s alpha component to be\n",
" // discarded, giving the text a black background instead of the\n",
" // background being transparent.\n",
" materialOptions.opacity = opacity;\n",
" }\n",
" var sprite = new THREE.Sprite( new THREE.SpriteMaterial( materialOptions ) );\n",
" sprite.position.set( x, y, z );\n",
"\n",
" // Scaling factor, chosen somewhat arbitrarily so that the size of the text\n",
" // is consistent with previously generated plots.\n",
" var scale = 1/625;\n",
" if ( options.projection === &#x27;orthographic&#x27; ) {\n",
" scale = midToCorner/256; // Needs to scale along with the plot itself.\n",
" }\n",
" sprite.scale.set( scale * width, scale * height, 1 );\n",
"\n",
" scene.add( sprite );\n",
"\n",
" return sprite;\n",
"\n",
" }\n",
"\n",
" if ( options.axes ) scene.add( new THREE.AxesHelper( Math.min( a[0]*b[1].x, a[1]*b[1].y, a[2]*b[1].z ) ) );\n",
"\n",
" var camera = createCamera();\n",
" camera.up.set( 0, 0, 1 );\n",
" camera.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid );\n",
"\n",
" // camera is positioned so that the line from the camera to the center\n",
" // of the bounding sphere of the objects makes an angle of 60 degrees with x-axis\n",
" // and an angle of 30 degrees with z-axis and the field of view of the camera looking\n",
" // at the center has an angle of 45 degrees.\n",
" const sin8 = Math.sin(Math.PI / 8);\n",
" const sin5 = Math.sin(Math.PI / 5);\n",
" const cos5 = Math.cos(Math.PI / 5);\n",
" const sin3 = Math.sin(Math.PI / 3);\n",
" const cos3 = Math.cos(Math.PI / 3);\n",
" var r = midToCorner / sin8;\n",
" var offset = new THREE.Vector3( r * sin3 * cos5, r * sin3 * sin5, r * cos3 );\n",
"\n",
" if ( options.viewpoint ) {\n",
"\n",
" var aa = options.viewpoint;\n",
" var axis = new THREE.Vector3( aa[0][0], aa[0][1], aa[0][2] ).normalize();\n",
" var angle = aa[1] * Math.PI / 180;\n",
" var q = new THREE.Quaternion().setFromAxisAngle( axis, angle ).inverse();\n",
"\n",
" offset.set( 0, 0, offset.length() );\n",
" offset.applyQuaternion( q );\n",
"\n",
" }\n",
"\n",
" camera.position.add( offset );\n",
"\n",
" function createCamera() {\n",
"\n",
" var aspect = window.innerWidth / window.innerHeight;\n",
"\n",
" // Scale the near and far clipping planes along with the overall plot size.\n",
" var nearClip = 0.01 * midToCorner;\n",
" var farClip = 100 * midToCorner;\n",
"\n",
" if ( options.projection === &#x27;orthographic&#x27; ) {\n",
" var camera = new THREE.OrthographicCamera( -1, 1, 1, -1, -farClip, farClip );\n",
" updateCameraAspect( camera, aspect );\n",
" return camera;\n",
" }\n",
"\n",
" return new THREE.PerspectiveCamera( 45, aspect, nearClip, farClip );\n",
"\n",
" }\n",
"\n",
" function updateCameraAspect( camera, aspect ) {\n",
"\n",
" if ( camera.isPerspectiveCamera ) {\n",
" camera.aspect = aspect;\n",
" } else if ( camera.isOrthographicCamera ) {\n",
" // Fit the camera frustum to the bounding box&#x27;s diagonal so that the entire plot fits\n",
" // within at the default zoom level and camera position.\n",
" if ( aspect &gt; 1 ) { // Wide window\n",
" camera.top = midToCorner;\n",
" camera.right = midToCorner * aspect;\n",
" } else { // Tall or square window\n",
" camera.top = midToCorner / aspect;\n",
" camera.right = midToCorner;\n",
" }\n",
" camera.bottom = -camera.top;\n",
" camera.left = -camera.right;\n",
" }\n",
"\n",
" camera.updateProjectionMatrix();\n",
"\n",
" }\n",
"\n",
" var lights = [{&quot;x&quot;:-5, &quot;y&quot;:3, &quot;z&quot;:0, &quot;color&quot;:&quot;#7f7f7f&quot;, &quot;parent&quot;:&quot;camera&quot;}];\n",
" for ( var i=0 ; i &lt; lights.length ; i++ ) {\n",
" var light = new THREE.DirectionalLight( lights[i].color, 1 );\n",
" light.position.set( a[0]*lights[i].x, a[1]*lights[i].y, a[2]*lights[i].z );\n",
" if ( lights[i].parent === &#x27;camera&#x27; ) {\n",
" light.target.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid );\n",
" scene.add( light.target );\n",
" camera.add( light );\n",
" } else scene.add( light );\n",
" }\n",
" scene.add( camera );\n",
"\n",
" var ambient = {&quot;color&quot;:&quot;#7f7f7f&quot;};\n",
" scene.add( new THREE.AmbientLight( ambient.color, 1 ) );\n",
"\n",
" var controls = new THREE.OrbitControls( camera, renderer.domElement );\n",
" controls.target.set( a[0]*xMid, a[1]*yMid, a[2]*zMid );\n",
" controls.addEventListener( &#x27;change&#x27;, function() { if ( !animate ) render(); } );\n",
"\n",
" window.addEventListener( &#x27;resize&#x27;, function() {\n",
"\n",
" renderer.setSize( window.innerWidth, window.innerHeight );\n",
" updateCameraAspect( camera, window.innerWidth / window.innerHeight );\n",
" if ( window.rescaleFatLines ) rescaleFatLines();\n",
" if ( !animate ) render();\n",
"\n",
" } );\n",
"\n",
" var texts = [];\n",
" for ( var i=0 ; i &lt; texts.length ; i++ ) addText( texts[i] );\n",
"\n",
" function addText( json ) {\n",
" var sprite = addLabel( json.text, a[0]*json.x, a[1]*json.y, a[2]*json.z, json );\n",
" sprite.userData = json;\n",
" }\n",
"\n",
" var points = [{&quot;point&quot;: [0.0, 0.0, 3.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 2.0, 1.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [2.0, 0.0, 1.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [4.0, 0.0, 0.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 0.0, 3.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 2.0, 1.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [2.0, 0.0, 1.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [4.0, 0.0, 0.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 0.0, 0.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#000000&quot;, &quot;opacity&quot;: 1.0}];\n",
" for ( var i=0 ; i &lt; points.length ; i++ ) addPoint( points[i] );\n",
"\n",
" function addPoint( json ) {\n",
"\n",
" var geometry = new THREE.Geometry();\n",
" var v = json.point;\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v[0], a[1]*v[1], a[2]*v[2] ) );\n",
"\n",
" var canvas = document.createElement( &#x27;canvas&#x27; );\n",
" canvas.width = 128;\n",
" canvas.height = 128;\n",
"\n",
" var context = canvas.getContext( &#x27;2d&#x27; );\n",
" context.arc( 64, 64, 64, 0, 2 * Math.PI );\n",
" context.fillStyle = json.color;\n",
" context.fill();\n",
"\n",
" var texture = new THREE.Texture( canvas );\n",
" texture.needsUpdate = true;\n",
"\n",
" var transparent = json.opacity &lt; 1 ? true : false;\n",
" var size = camera.isOrthographicCamera ? json.size : json.size/100;\n",
" var material = new THREE.PointsMaterial( { size: size, map: texture,\n",
" transparent: transparent, opacity: json.opacity,\n",
" alphaTest: .1 } );\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var mesh = new THREE.Points( geometry, material );\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" }\n",
"\n",
" var lines = [{&quot;points&quot;: [[0.0, 0.0, 3.0], [0.0, 2.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[0.0, 0.0, 3.0], [2.0, 0.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[0.0, 2.0, 1.0], [2.0, 0.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[0.0, 2.0, 1.0], [4.0, 0.0, 0.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[2.0, 0.0, 1.0], [4.0, 0.0, 0.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}];\n",
" for ( var i=0 ; i &lt; lines.length ; i++ ) addLine( lines[i] );\n",
"\n",
" function addLine( json ) {\n",
"\n",
" var geometry = new THREE.Geometry();\n",
" for ( var i=0 ; i &lt; json.points.length ; i++ ) {\n",
" var v = json.points[i];\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v[0], a[1]*v[1], a[2]*v[2] ) );\n",
" }\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var transparent = json.opacity &lt; 1 ? true : false;\n",
" var materialOptions = { color: json.color, linewidth: json.linewidth,\n",
" transparent: transparent, opacity: json.opacity };\n",
"\n",
" var mesh;\n",
" if ( json.linewidth &gt; 1 &amp;&amp; window.createFatLineStrip ) {\n",
" mesh = createFatLineStrip( geometry, materialOptions );\n",
" } else {\n",
" var material = new THREE.LineBasicMaterial( materialOptions );\n",
" mesh = new THREE.Line( geometry, material );\n",
" }\n",
"\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" }\n",
"\n",
" var surfaces = [{&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.02, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.02, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: 3.0}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 3.0}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 4.0}, {&quot;x&quot;: 0.05706339097770921, &quot;y&quot;: 0.018541019662496848, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.06, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.03526711513754839, &quot;y&quot;: -0.04854101966249684, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.03526711513754838, &quot;y&quot;: -0.048541019662496854, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.05706339097770922, &quot;y&quot;: 0.018541019662496834, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.8200000000000003}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.0}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9938196601125011}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9800000000000001}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9938196601125011}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 2.0, &quot;z&quot;: 0.993819660112501}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.0, &quot;z&quot;: 0.98}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: 2.0, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: 2.0, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 2.0, &quot;z&quot;: 0.993819660112501}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.0, &quot;z&quot;: 1.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 3.0000000000000004, &quot;z&quot;: 1.0}, {&quot;x&quot;: 0.05706339097770921, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9814589803375031}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.94}, {&quot;x&quot;: 0.03526711513754839, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.048541019662497}, {&quot;x&quot;: -0.03526711513754838, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.048541019662497}, {&quot;x&quot;: -0.05706339097770922, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9814589803375031}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.019021130325903, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.006180339887498899}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.019999999999999952}, {&quot;x&quot;: 4.011755705045849, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.016180339887498996}, {&quot;x&quot;: 3.9882442949541503, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.016180339887499}, {&quot;x&quot;: 3.980978869674097, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.006180339887498895}, {&quot;x&quot;: 4.019021130325903, &quot;y&quot;: 3.7843667304341507e-19, &quot;z&quot;: -0.006180339887498949}, {&quot;x&quot;: 4.0, &quot;y&quot;: 1.2246467991473532e-18, &quot;z&quot;: -0.02}, {&quot;x&quot;: 4.011755705045849, &quot;y&quot;: -9.907600726170915e-19, &quot;z&quot;: 0.016180339887498948}, {&quot;x&quot;: 3.9882442949541503, &quot;y&quot;: -9.907600726170917e-19, &quot;z&quot;: 0.01618033988749895}, {&quot;x&quot;: 3.980978869674097, &quot;y&quot;: 3.784366730434148e-19, &quot;z&quot;: -0.006180339887498945}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 4.0, &quot;y&quot;: 1.0, &quot;z&quot;: 6.123233995736767e-17}, {&quot;x&quot;: 4.057063390977709, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.0185410196624968}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.05999999999999995}, {&quot;x&quot;: 4.0352671151375485, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.04854101966249689}, {&quot;x&quot;: 3.9647328848624515, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.0485410196624969}, {&quot;x&quot;: 3.942936609022291, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.018541019662496785}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 5.021051876504149e-17}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 4.82, &quot;y&quot;: 0.0, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: -0.019021130325903024}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.02, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: -0.011755705045849415}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 0.011755705045849512}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 0.01902113032590312}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: -0.019021130325903073}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.02, &quot;z&quot;: 0.0}, {&quot;x&quot;: 4.0, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: -0.011755705045849465}, {&quot;x&quot;: 4.0, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 0.011755705045849461}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 0.019021130325903073}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 5.0, &quot;y&quot;: 0.0, &quot;z&quot;: 6.123233995736767e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.018541019662496848, &quot;z&quot;: -0.05706339097770916}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.06, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.04854101966249684, &quot;z&quot;: -0.03526711513754834}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.048541019662496854, &quot;z&quot;: 0.035267115137548426}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.018541019662496834, &quot;z&quot;: 0.057063390977709266}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.0, &quot;z&quot;: 5.021051876504149e-17}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.0, &quot;z&quot;: 1.0}, {&quot;x&quot;: 2.0, &quot;y&quot;: 0.0, &quot;z&quot;: 1.0}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 4.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 3.0, &quot;z&quot;: 1.0}, {&quot;x&quot;: 4.0, &quot;y&quot;: 1.0, &quot;z&quot;: 0.0}, {&quot;x&quot;: 5.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}], &quot;faces&quot;: [[7, 3, 2, 0, 4], [2, 0, 1], [4, 0, 1, 5], [3, 6, 5, 1], [2, 1, 3], [6, 3, 7]], &quot;color&quot;: &quot;#008000&quot;, &quot;opacity&quot;: 1.0, &quot;useFlatShading&quot;: true}];\n",
" for ( var i=0 ; i &lt; surfaces.length ; i++ ) addSurface( surfaces[i] );\n",
"\n",
" function addSurface( json ) {\n",
"\n",
" var useFaceColors = &#x27;faceColors&#x27; in json ? true : false;\n",
"\n",
" var geometry = new THREE.Geometry();\n",
" for ( var i=0 ; i &lt; json.vertices.length ; i++ ) {\n",
" var v = json.vertices[i];\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v.x, a[1]*v.y, a[2]*v.z ) );\n",
" }\n",
" for ( var i=0 ; i &lt; json.faces.length ; i++ ) {\n",
" var f = json.faces[i];\n",
" for ( var j=0 ; j &lt; f.length - 2 ; j++ ) {\n",
" var face = new THREE.Face3( f[0], f[j+1], f[j+2] );\n",
" if ( useFaceColors ) face.color.set( json.faceColors[i] );\n",
" geometry.faces.push( face );\n",
" }\n",
" }\n",
" geometry.computeVertexNormals();\n",
"\n",
" var side = json.singleSide ? THREE.FrontSide : THREE.DoubleSide;\n",
" var transparent = json.opacity &lt; 1 ? true : false;\n",
" var depthWrite = &#x27;depthWrite&#x27; in json ? json.depthWrite : !transparent;\n",
" var flatShading = json.useFlatShading ? json.useFlatShading : false;\n",
"\n",
" var material = new THREE.MeshPhongMaterial( { side: side,\n",
" color: useFaceColors ? &#x27;white&#x27; : json.color,\n",
" vertexColors: useFaceColors ? THREE.FaceColors : THREE.NoColors,\n",
" transparent: transparent, opacity: json.opacity,\n",
" shininess: 20, flatShading: flatShading,\n",
" depthWrite: depthWrite } );\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var mesh = new THREE.Mesh( geometry, material );\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" if ( transparent &amp;&amp; json.renderOrder ) mesh.renderOrder = json.renderOrder;\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" if ( json.showMeshGrid ) addSurfaceMeshGrid( json );\n",
"\n",
" }\n",
"\n",
" function addSurfaceMeshGrid( json ) {\n",
"\n",
" var geometry = new THREE.Geometry();\n",
"\n",
" for ( var i=0 ; i &lt; json.faces.length ; i++ ) {\n",
" var f = json.faces[i];\n",
" for ( var j=0 ; j &lt; f.length ; j++ ) {\n",
" var k = j === f.length-1 ? 0 : j+1;\n",
" var v1 = json.vertices[f[j]];\n",
" var v2 = json.vertices[f[k]];\n",
" // vertices in opposite directions on neighboring faces\n",
" var nudge = f[j] &lt; f[k] ? .0005*zRange : -.0005*zRange;\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v1.x, a[1]*v1.y, a[2]*(v1.z+nudge) ) );\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v2.x, a[1]*v2.y, a[2]*(v2.z+nudge) ) );\n",
" }\n",
" }\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var gridColor = options.theme === &#x27;dark&#x27; ? &#x27;white&#x27; : &#x27;black&#x27;;\n",
" var linewidth = json.linewidth || 1;\n",
" var materialOptions = { color: gridColor, linewidth: linewidth };\n",
"\n",
" var mesh;\n",
" if ( linewidth &gt; 1 &amp;&amp; window.createFatLineSegments ) {\n",
" mesh = createFatLineSegments( geometry, materialOptions );\n",
" } else {\n",
" var material = new THREE.LineBasicMaterial( materialOptions );\n",
" mesh = new THREE.LineSegments( geometry, material );\n",
" }\n",
"\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" }\n",
"\n",
" function render() {\n",
"\n",
" if ( window.updateAnimation ) animate = updateAnimation();\n",
" if ( animate ) requestAnimationFrame( render );\n",
"\n",
" renderer.render( scene, camera );\n",
"\n",
" }\n",
"\n",
" render();\n",
" controls.update();\n",
" if ( !animate ) render();\n",
"\n",
"\n",
" // menu functions\n",
"\n",
" function toggleMenu() {\n",
"\n",
" var m = document.getElementById( &#x27;menu-content&#x27; );\n",
" if ( m.style.display === &#x27;block&#x27; ) m.style.display = &#x27;none&#x27;\n",
" else m.style.display = &#x27;block&#x27;;\n",
"\n",
" }\n",
"\n",
"\n",
" function saveAsPNG() {\n",
"\n",
" var a = document.body.appendChild( document.createElement( &#x27;a&#x27; ) );\n",
" a.href = renderer.domElement.toDataURL( &#x27;image/png&#x27; );\n",
" a.download = &#x27;screenshot&#x27;;\n",
" a.click();\n",
"\n",
" }\n",
"\n",
" function saveAsHTML() {\n",
"\n",
" toggleMenu(); // otherwise visible in output\n",
" event.stopPropagation();\n",
"\n",
" var blob = new Blob( [ &#x27;&lt;!DOCTYPE html&gt;\\n&#x27; + document.documentElement.outerHTML ] );\n",
" var a = document.body.appendChild( document.createElement( &#x27;a&#x27; ) );\n",
" a.href = window.URL.createObjectURL( blob );\n",
" a.download = suggestFilename();\n",
" a.click();\n",
"\n",
" function suggestFilename() {\n",
" if ( !document.title ) {\n",
" return &#x27;graphic.html&#x27;;\n",
" } else if ( /\\.html?$/i.test( document.title ) ) {\n",
" return document.title; // already ends in .htm or .html\n",
" } else {\n",
" return document.title + &#x27;.html&#x27;;\n",
" }\n",
" }\n",
"\n",
" }\n",
"\n",
" function getViewpoint() {\n",
"\n",
" function roundTo( x, n ) { return +x.toFixed(n); }\n",
"\n",
" var v = camera.quaternion.inverse();\n",
" var r = Math.sqrt( v.x*v.x + v.y*v.y + v.z*v.z );\n",
" var axis = [ roundTo( v.x / r, 4 ), roundTo( v.y / r, 4 ), roundTo( v.z / r, 4 ) ];\n",
" var angle = roundTo( 2 * Math.atan2( r, v.w ) * 180 / Math.PI, 2 );\n",
"\n",
" var textArea = document.createElement( &#x27;textarea&#x27; );\n",
" textArea.textContent = JSON.stringify( axis ) + &#x27;,&#x27; + angle;\n",
" textArea.style.csstext = &#x27;position: absolute; top: -100%&#x27;;\n",
" document.body.append( textArea );\n",
" textArea.select();\n",
" document.execCommand( &#x27;copy&#x27; );\n",
"\n",
" var m = document.getElementById( &#x27;menu-message&#x27; );\n",
" m.innerHTML = &#x27;Viewpoint copied to clipboard&#x27;;\n",
" m.style.display = &#x27;block&#x27;;\n",
" setTimeout( function() { m.style.display = &#x27;none&#x27;; }, 2000 );\n",
"\n",
" }\n",
"\n",
" function getCamera() {\n",
"\n",
" function roundTo( x, n ) { return +x.toFixed(n); }\n",
"\n",
" var pos = camera.position;\n",
" var pos_r = [ roundTo( pos.x, 4 ), roundTo( pos.y, 4 ), roundTo( pos.z, 4 ) ];\n",
" // var up = camera.up; // up is always (0,0,1)\n",
" var textArea = document.createElement(&#x27;textarea&#x27;);\n",
" var cam_position = JSON.stringify(pos_r);\n",
" textArea.textContent = &#x27;,camera_position=&#x27; + cam_position;\n",
" textArea.style.csstext = &#x27;position: absolute; top: -100%&#x27;;\n",
" document.body.append( textArea );\n",
" textArea.select();\n",
" document.execCommand( &#x27;copy&#x27; );\n",
"\n",
" var m = document.getElementById( &#x27;menu-message&#x27; );\n",
" m.innerHTML = &#x27;Camera position &#x27;+ cam_position+&#x27; copied to clipboard&#x27;;\n",
" m.style.display = &#x27;block&#x27;;\n",
" setTimeout( function() { m.style.display = &#x27;none&#x27;; }, 2000 );\n",
"\n",
" }\n",
"\n",
"&lt;/script&gt;\n",
"\n",
"&lt;div id=&quot;menu-container&quot; onclick=&quot;toggleMenu()&quot;&gt;&amp;#x24d8;\n",
"&lt;div id=&quot;menu-message&quot;&gt;&lt;/div&gt;\n",
"&lt;div id=&quot;menu-content&quot;&gt;\n",
"&lt;div onclick=&quot;saveAsPNG()&quot;&gt;Save as PNG&lt;/div&gt;\n",
"&lt;div onclick=&quot;saveAsHTML()&quot;&gt;Save as HTML&lt;/div&gt;\n",
"&lt;div onclick=&quot;getCamera()&quot;&gt;Get camera&lt;/div&gt;\n",
"&lt;div onclick=&quot;getViewpoint()&quot;&gt;Get viewpoint&lt;/div&gt;\n",
"&lt;div&gt;Close Menu&lt;/div&gt;\n",
"&lt;/div&gt;&lt;/div&gt;\n",
"\n",
"\n",
"&lt;/body&gt;\n",
"&lt;/html&gt;\n",
"\"\n",
" width=\"100%\"\n",
" height=\"400\"\n",
" style=\"border: 0;\">\n",
"</iframe>\n"
],
"text/plain": [
"Graphics3d Object"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Z.newton_plot()"
]
},
{
"cell_type": "code",
"execution_count": 28,
"id": "9ce635a7-c084-458e-889c-62d791adbf57",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"<iframe srcdoc=\"&lt;!DOCTYPE html&gt;\n",
"&lt;html&gt;\n",
"&lt;head&gt;\n",
"&lt;title&gt;&lt;/title&gt;\n",
"&lt;meta charset=&quot;utf-8&quot;&gt;\n",
"&lt;meta name=viewport content=&quot;width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0&quot;&gt;\n",
"&lt;style&gt;\n",
"\n",
" body { margin: 0px; overflow: hidden; }\n",
"\n",
" #menu-container { position: absolute; bottom: 30px; right: 40px; cursor: default; }\n",
"\n",
" #menu-message { position: absolute; bottom: 0px; right: 0px; white-space: nowrap;\n",
" display: none; background-color: #F5F5F5; padding: 10px; }\n",
"\n",
" #menu-content { position: absolute; bottom: 0px; right: 0px;\n",
" display: none; background-color: #F5F5F5; border-bottom: 1px solid black;\n",
" border-right: 1px solid black; border-left: 1px solid black; }\n",
"\n",
" #menu-content div { border-top: 1px solid black; padding: 10px; white-space: nowrap; }\n",
"\n",
" #menu-content div:hover { background-color: #FEFEFE; }\n",
"\n",
" .dark-theme #menu-container { color: white; }\n",
"\n",
" .dark-theme #menu-message { background-color: #181818; }\n",
"\n",
" .dark-theme #menu-content { background-color: #181818; border-color: white; }\n",
"\n",
" .dark-theme #menu-content div { border-color: white; }\n",
"\n",
" .dark-theme #menu-content div:hover { background-color: #303030; }\n",
"\n",
"&lt;/style&gt;\n",
"\n",
"&lt;/head&gt;\n",
"\n",
"&lt;body&gt;\n",
"\n",
"&lt;script src=&quot;/nbextensions/threejs-sage/r122/three.min.js&quot;&gt;&lt;/script&gt;\n",
"&lt;script&gt;\n",
" if ( !window.THREE ) document.write(&#x27; \\\n",
"&lt;script src=&quot;https://cdn.jsdelivr.net/gh/sagemath/threejs-sage@r122/build/three.min.js&quot;&gt;&lt;\\/script&gt; \\\n",
" &#x27;);\n",
"&lt;/script&gt;\n",
" \n",
"&lt;script&gt;\n",
"\n",
" var options = {&quot;animate&quot;: false, &quot;animationControls&quot;: true, &quot;aspectRatio&quot;: [1.0, 1.0, 1.0], &quot;autoScaling&quot;: [false, false, false], &quot;autoPlay&quot;: true, &quot;axes&quot;: false, &quot;axesLabels&quot;: [&quot;x&quot;, &quot;y&quot;, &quot;z&quot;], &quot;axesLabelsStyle&quot;: null, &quot;decimals&quot;: 2, &quot;delay&quot;: 20, &quot;frame&quot;: true, &quot;loop&quot;: true, &quot;projection&quot;: &quot;perspective&quot;, &quot;theme&quot;: &quot;light&quot;, &quot;viewpoint&quot;: false};\n",
" var animate = options.animate;\n",
"\n",
" if ( options.theme === &#x27;dark&#x27; )\n",
" document.body.className = &#x27;dark-theme&#x27;;\n",
"\n",
" var scene = new THREE.Scene();\n",
"\n",
" var renderer = new THREE.WebGLRenderer( { antialias: true, preserveDrawingBuffer: true } );\n",
" renderer.setPixelRatio( window.devicePixelRatio );\n",
" renderer.setSize( window.innerWidth, window.innerHeight );\n",
" renderer.setClearColor( options.theme === &#x27;dark&#x27; ? 0 : 0xffffff, 1 );\n",
" document.body.appendChild( renderer.domElement );\n",
"\n",
" var b = [{&quot;x&quot;:-0.05706339097770922, &quot;y&quot;:-0.048541019662496854, &quot;z&quot;:-0.05999999999999995}, {&quot;x&quot;:5.0, &quot;y&quot;:3.0, &quot;z&quot;:4.0}]; // bounds\n",
"\n",
" if ( b[0].x === b[1].x ) {\n",
" b[0].x -= 1;\n",
" b[1].x += 1;\n",
" }\n",
" if ( b[0].y === b[1].y ) {\n",
" b[0].y -= 1;\n",
" b[1].y += 1;\n",
" }\n",
" if ( b[0].z === b[1].z ) {\n",
" b[0].z -= 1;\n",
" b[1].z += 1;\n",
" }\n",
"\n",
" var rxRange = Math.sqrt( Math.pow( b[1].z - b[0].z, 2 )\n",
" + Math.pow( b[1].y - b[0].y, 2 ) );\n",
" var ryRange = Math.sqrt( Math.pow( b[1].x - b[0].x, 2 )\n",
" + Math.pow( b[1].z - b[0].z, 2 ) );\n",
" var rzRange = Math.sqrt( Math.pow( b[1].x - b[0].x, 2 )\n",
" + Math.pow( b[1].y - b[0].y, 2 ) );\n",
" var xRange = b[1].x - b[0].x;\n",
" var yRange = b[1].y - b[0].y;\n",
" var zRange = b[1].z - b[0].z;\n",
"\n",
" var ar = options.aspectRatio;\n",
" var a = [ ar[0], ar[1], ar[2] ]; // aspect multipliers\n",
"\n",
" var autoScaling = options.autoScaling;\n",
" var autoAspect = 2.5;\n",
" if ( xRange &gt; autoAspect * rxRange &amp;&amp; autoScaling[0] ) a[0] = autoAspect * rxRange / xRange;\n",
" if ( yRange &gt; autoAspect * ryRange &amp;&amp; autoScaling[1] ) a[1] = autoAspect * ryRange / yRange;\n",
" if ( zRange &gt; autoAspect * rzRange &amp;&amp; autoScaling[2] ) a[2] = autoAspect * rzRange / zRange;\n",
"\n",
" // Distance from (xMid,yMid,zMid) to any corner of the bounding box, after applying aspectRatio\n",
" var midToCorner = Math.sqrt( a[0]*a[0]*xRange*xRange + a[1]*a[1]*yRange*yRange + a[2]*a[2]*zRange*zRange ) / 2;\n",
"\n",
" var xMid = ( b[0].x + b[1].x ) / 2;\n",
" var yMid = ( b[0].y + b[1].y ) / 2;\n",
" var zMid = ( b[0].z + b[1].z ) / 2;\n",
"\n",
" var box = new THREE.Geometry();\n",
" box.vertices.push( new THREE.Vector3( a[0]*b[0].x, a[1]*b[0].y, a[2]*b[0].z ) );\n",
" box.vertices.push( new THREE.Vector3( a[0]*b[1].x, a[1]*b[1].y, a[2]*b[1].z ) );\n",
" var boxMesh = new THREE.Line( box );\n",
" var boxColor = options.theme === &#x27;dark&#x27; ? &#x27;white&#x27; : &#x27;black&#x27;;\n",
" if ( options.frame ) scene.add( new THREE.BoxHelper( boxMesh, boxColor ) );\n",
"\n",
" if ( options.axesLabels ) {\n",
"\n",
" var d = options.decimals; // decimals\n",
" var offsetRatio = 0.1;\n",
" var al = options.axesLabels;\n",
" var als = options.axesLabelsStyle || [{}, {}, {}];\n",
"\n",
" var offset = offsetRatio * a[1]*( b[1].y - b[0].y );\n",
" var xm = xMid.toFixed(d);\n",
" if ( /^-0.?0*$/.test(xm) ) xm = xm.substr(1);\n",
" addLabel( al[0] + &#x27;=&#x27; + xm, a[0]*xMid, a[1]*b[1].y+offset, a[2]*b[0].z, als[0] );\n",
" addLabel( ( b[0].x ).toFixed(d), a[0]*b[0].x, a[1]*b[1].y+offset, a[2]*b[0].z, als[0] );\n",
" addLabel( ( b[1].x ).toFixed(d), a[0]*b[1].x, a[1]*b[1].y+offset, a[2]*b[0].z, als[0] );\n",
"\n",
" var offset = offsetRatio * a[0]*( b[1].x - b[0].x );\n",
" var ym = yMid.toFixed(d);\n",
" if ( /^-0.?0*$/.test(ym) ) ym = ym.substr(1);\n",
" addLabel( al[1] + &#x27;=&#x27; + ym, a[0]*b[1].x+offset, a[1]*yMid, a[2]*b[0].z, als[1] );\n",
" addLabel( ( b[0].y ).toFixed(d), a[0]*b[1].x+offset, a[1]*b[0].y, a[2]*b[0].z, als[1] );\n",
" addLabel( ( b[1].y ).toFixed(d), a[0]*b[1].x+offset, a[1]*b[1].y, a[2]*b[0].z, als[1] );\n",
"\n",
" var offset = offsetRatio * a[1]*( b[1].y - b[0].y );\n",
" var zm = zMid.toFixed(d);\n",
" if ( /^-0.?0*$/.test(zm) ) zm = zm.substr(1);\n",
" addLabel( al[2] + &#x27;=&#x27; + zm, a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*zMid, als[2] );\n",
" addLabel( ( b[0].z ).toFixed(d), a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*b[0].z, als[2] );\n",
" addLabel( ( b[1].z ).toFixed(d), a[0]*b[1].x, a[1]*b[0].y-offset, a[2]*b[1].z, als[2] );\n",
"\n",
" }\n",
"\n",
" function addLabel( text, x, y, z, style ) {\n",
"\n",
" var color = style.color || &#x27;black&#x27;;\n",
" var fontSize = style.fontSize || 14;\n",
" var fontFamily = style.fontFamily || &#x27;monospace&#x27;;\n",
" var fontStyle = style.fontStyle || &#x27;normal&#x27;;\n",
" var fontWeight = style.fontWeight || &#x27;normal&#x27;;\n",
" var opacity = style.opacity || 1;\n",
"\n",
" if ( options.theme === &#x27;dark&#x27; )\n",
" if ( color === &#x27;black&#x27; || color === &#x27;#000000&#x27; )\n",
" color = &#x27;white&#x27;;\n",
"\n",
" if ( Array.isArray( fontStyle ) ) {\n",
" fontFamily = fontFamily.map( function( f ) {\n",
" // Need to put quotes around fonts that have whitespace in their names.\n",
" return /\\s/.test( f ) ? &#x27;&quot;&#x27; + f + &#x27;&quot;&#x27; : f;\n",
" }).join(&#x27;, &#x27;);\n",
" }\n",
"\n",
" var canvas = document.createElement( &#x27;canvas&#x27; );\n",
" var context = canvas.getContext( &#x27;2d&#x27; );\n",
" var pixelRatio = Math.round( window.devicePixelRatio );\n",
"\n",
" // For example: italic bold 20px &quot;Times New Roman&quot;, Georgia, serif\n",
" var font = [fontStyle, fontWeight, fontSize + &#x27;px&#x27;, fontFamily].join(&#x27; &#x27;);\n",
"\n",
" context.font = font;\n",
" var width = context.measureText( text ).width;\n",
" var height = fontSize;\n",
"\n",
" // The dimensions of the canvas&#x27;s underlying image data need to be powers\n",
" // of two in order for the resulting texture to support mipmapping.\n",
" canvas.width = THREE.MathUtils.ceilPowerOfTwo( width * pixelRatio );\n",
" canvas.height = THREE.MathUtils.ceilPowerOfTwo( height * pixelRatio );\n",
"\n",
" // Re-compute the unscaled dimensions after the power of two conversion.\n",
" width = canvas.width / pixelRatio;\n",
" height = canvas.height / pixelRatio;\n",
"\n",
" canvas.style.width = width + &#x27;px&#x27;;\n",
" canvas.style.height = height + &#x27;px&#x27;;\n",
"\n",
" context.scale( pixelRatio, pixelRatio );\n",
" context.fillStyle = color;\n",
" context.font = font; // Must be set again after measureText.\n",
" context.textAlign = &#x27;center&#x27;;\n",
" context.textBaseline = &#x27;middle&#x27;;\n",
" context.fillText( text, width/2, height/2 );\n",
"\n",
" var texture = new THREE.Texture( canvas );\n",
" texture.needsUpdate = true;\n",
"\n",
" var materialOptions = { map: texture, sizeAttenuation: false, depthWrite: false };\n",
" if ( opacity &lt; 1 ) {\n",
" // Setting opacity=1 would cause the texture&#x27;s alpha component to be\n",
" // discarded, giving the text a black background instead of the\n",
" // background being transparent.\n",
" materialOptions.opacity = opacity;\n",
" }\n",
" var sprite = new THREE.Sprite( new THREE.SpriteMaterial( materialOptions ) );\n",
" sprite.position.set( x, y, z );\n",
"\n",
" // Scaling factor, chosen somewhat arbitrarily so that the size of the text\n",
" // is consistent with previously generated plots.\n",
" var scale = 1/625;\n",
" if ( options.projection === &#x27;orthographic&#x27; ) {\n",
" scale = midToCorner/256; // Needs to scale along with the plot itself.\n",
" }\n",
" sprite.scale.set( scale * width, scale * height, 1 );\n",
"\n",
" scene.add( sprite );\n",
"\n",
" return sprite;\n",
"\n",
" }\n",
"\n",
" if ( options.axes ) scene.add( new THREE.AxesHelper( Math.min( a[0]*b[1].x, a[1]*b[1].y, a[2]*b[1].z ) ) );\n",
"\n",
" var camera = createCamera();\n",
" camera.up.set( 0, 0, 1 );\n",
" camera.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid );\n",
"\n",
" // camera is positioned so that the line from the camera to the center\n",
" // of the bounding sphere of the objects makes an angle of 60 degrees with x-axis\n",
" // and an angle of 30 degrees with z-axis and the field of view of the camera looking\n",
" // at the center has an angle of 45 degrees.\n",
" const sin8 = Math.sin(Math.PI / 8);\n",
" const sin5 = Math.sin(Math.PI / 5);\n",
" const cos5 = Math.cos(Math.PI / 5);\n",
" const sin3 = Math.sin(Math.PI / 3);\n",
" const cos3 = Math.cos(Math.PI / 3);\n",
" var r = midToCorner / sin8;\n",
" var offset = new THREE.Vector3( r * sin3 * cos5, r * sin3 * sin5, r * cos3 );\n",
"\n",
" if ( options.viewpoint ) {\n",
"\n",
" var aa = options.viewpoint;\n",
" var axis = new THREE.Vector3( aa[0][0], aa[0][1], aa[0][2] ).normalize();\n",
" var angle = aa[1] * Math.PI / 180;\n",
" var q = new THREE.Quaternion().setFromAxisAngle( axis, angle ).inverse();\n",
"\n",
" offset.set( 0, 0, offset.length() );\n",
" offset.applyQuaternion( q );\n",
"\n",
" }\n",
"\n",
" camera.position.add( offset );\n",
"\n",
" function createCamera() {\n",
"\n",
" var aspect = window.innerWidth / window.innerHeight;\n",
"\n",
" // Scale the near and far clipping planes along with the overall plot size.\n",
" var nearClip = 0.01 * midToCorner;\n",
" var farClip = 100 * midToCorner;\n",
"\n",
" if ( options.projection === &#x27;orthographic&#x27; ) {\n",
" var camera = new THREE.OrthographicCamera( -1, 1, 1, -1, -farClip, farClip );\n",
" updateCameraAspect( camera, aspect );\n",
" return camera;\n",
" }\n",
"\n",
" return new THREE.PerspectiveCamera( 45, aspect, nearClip, farClip );\n",
"\n",
" }\n",
"\n",
" function updateCameraAspect( camera, aspect ) {\n",
"\n",
" if ( camera.isPerspectiveCamera ) {\n",
" camera.aspect = aspect;\n",
" } else if ( camera.isOrthographicCamera ) {\n",
" // Fit the camera frustum to the bounding box&#x27;s diagonal so that the entire plot fits\n",
" // within at the default zoom level and camera position.\n",
" if ( aspect &gt; 1 ) { // Wide window\n",
" camera.top = midToCorner;\n",
" camera.right = midToCorner * aspect;\n",
" } else { // Tall or square window\n",
" camera.top = midToCorner / aspect;\n",
" camera.right = midToCorner;\n",
" }\n",
" camera.bottom = -camera.top;\n",
" camera.left = -camera.right;\n",
" }\n",
"\n",
" camera.updateProjectionMatrix();\n",
"\n",
" }\n",
"\n",
" var lights = [{&quot;x&quot;:-5, &quot;y&quot;:3, &quot;z&quot;:0, &quot;color&quot;:&quot;#7f7f7f&quot;, &quot;parent&quot;:&quot;camera&quot;}];\n",
" for ( var i=0 ; i &lt; lights.length ; i++ ) {\n",
" var light = new THREE.DirectionalLight( lights[i].color, 1 );\n",
" light.position.set( a[0]*lights[i].x, a[1]*lights[i].y, a[2]*lights[i].z );\n",
" if ( lights[i].parent === &#x27;camera&#x27; ) {\n",
" light.target.position.set( a[0]*xMid, a[1]*yMid, a[2]*zMid );\n",
" scene.add( light.target );\n",
" camera.add( light );\n",
" } else scene.add( light );\n",
" }\n",
" scene.add( camera );\n",
"\n",
" var ambient = {&quot;color&quot;:&quot;#7f7f7f&quot;};\n",
" scene.add( new THREE.AmbientLight( ambient.color, 1 ) );\n",
"\n",
" var controls = new THREE.OrbitControls( camera, renderer.domElement );\n",
" controls.target.set( a[0]*xMid, a[1]*yMid, a[2]*zMid );\n",
" controls.addEventListener( &#x27;change&#x27;, function() { if ( !animate ) render(); } );\n",
"\n",
" window.addEventListener( &#x27;resize&#x27;, function() {\n",
"\n",
" renderer.setSize( window.innerWidth, window.innerHeight );\n",
" updateCameraAspect( camera, window.innerWidth / window.innerHeight );\n",
" if ( window.rescaleFatLines ) rescaleFatLines();\n",
" if ( !animate ) render();\n",
"\n",
" } );\n",
"\n",
" var texts = [];\n",
" for ( var i=0 ; i &lt; texts.length ; i++ ) addText( texts[i] );\n",
"\n",
" function addText( json ) {\n",
" var sprite = addLabel( json.text, a[0]*json.x, a[1]*json.y, a[2]*json.z, json );\n",
" sprite.userData = json;\n",
" }\n",
"\n",
" var points = [{&quot;point&quot;: [0.0, 0.0, 3.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 2.0, 1.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [4.0, 0.0, 0.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [2.0, 0.0, 1.0], &quot;size&quot;: 10.0, &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 0.0, 3.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 2.0, 1.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [2.0, 0.0, 1.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [4.0, 0.0, 0.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#ff0000&quot;, &quot;opacity&quot;: 1.0}, {&quot;point&quot;: [0.0, 0.0, 0.0], &quot;size&quot;: 30.0, &quot;color&quot;: &quot;#000000&quot;, &quot;opacity&quot;: 1.0}];\n",
" for ( var i=0 ; i &lt; points.length ; i++ ) addPoint( points[i] );\n",
"\n",
" function addPoint( json ) {\n",
"\n",
" var geometry = new THREE.Geometry();\n",
" var v = json.point;\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v[0], a[1]*v[1], a[2]*v[2] ) );\n",
"\n",
" var canvas = document.createElement( &#x27;canvas&#x27; );\n",
" canvas.width = 128;\n",
" canvas.height = 128;\n",
"\n",
" var context = canvas.getContext( &#x27;2d&#x27; );\n",
" context.arc( 64, 64, 64, 0, 2 * Math.PI );\n",
" context.fillStyle = json.color;\n",
" context.fill();\n",
"\n",
" var texture = new THREE.Texture( canvas );\n",
" texture.needsUpdate = true;\n",
"\n",
" var transparent = json.opacity &lt; 1 ? true : false;\n",
" var size = camera.isOrthographicCamera ? json.size : json.size/100;\n",
" var material = new THREE.PointsMaterial( { size: size, map: texture,\n",
" transparent: transparent, opacity: json.opacity,\n",
" alphaTest: .1 } );\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var mesh = new THREE.Points( geometry, material );\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" }\n",
"\n",
" var lines = [{&quot;points&quot;: [[0.0, 0.0, 3.0], [0.0, 2.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[0.0, 0.0, 3.0], [2.0, 0.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[0.0, 2.0, 1.0], [4.0, 0.0, 0.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[0.0, 2.0, 1.0], [2.0, 0.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;points&quot;: [[4.0, 0.0, 0.0], [2.0, 0.0, 1.0]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}];\n",
" for ( var i=0 ; i &lt; lines.length ; i++ ) addLine( lines[i] );\n",
"\n",
" function addLine( json ) {\n",
"\n",
" var geometry = new THREE.Geometry();\n",
" for ( var i=0 ; i &lt; json.points.length ; i++ ) {\n",
" var v = json.points[i];\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v[0], a[1]*v[1], a[2]*v[2] ) );\n",
" }\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var transparent = json.opacity &lt; 1 ? true : false;\n",
" var materialOptions = { color: json.color, linewidth: json.linewidth,\n",
" transparent: transparent, opacity: json.opacity };\n",
"\n",
" var mesh;\n",
" if ( json.linewidth &gt; 1 &amp;&amp; window.createFatLineStrip ) {\n",
" mesh = createFatLineStrip( geometry, materialOptions );\n",
" } else {\n",
" var material = new THREE.LineBasicMaterial( materialOptions );\n",
" mesh = new THREE.Line( geometry, material );\n",
" }\n",
"\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" }\n",
"\n",
" var surfaces = [{&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.02, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.02, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: 3.0}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 3.0}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 4.0}, {&quot;x&quot;: 0.05706339097770921, &quot;y&quot;: 0.018541019662496848, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.06, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.03526711513754839, &quot;y&quot;: -0.04854101966249684, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.03526711513754838, &quot;y&quot;: -0.048541019662496854, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: -0.05706339097770922, &quot;y&quot;: 0.018541019662496834, &quot;z&quot;: 3.8200000000000003}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.8200000000000003}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.0}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9938196601125011}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9800000000000001}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9938196601125011}, {&quot;x&quot;: 0.019021130325903073, &quot;y&quot;: 2.0, &quot;z&quot;: 0.993819660112501}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.0, &quot;z&quot;: 0.98}, {&quot;x&quot;: 0.011755705045849465, &quot;y&quot;: 2.0, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.011755705045849461, &quot;y&quot;: 2.0, &quot;z&quot;: 1.016180339887499}, {&quot;x&quot;: -0.019021130325903073, &quot;y&quot;: 2.0, &quot;z&quot;: 0.993819660112501}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.0, &quot;z&quot;: 1.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 3.0000000000000004, &quot;z&quot;: 1.0}, {&quot;x&quot;: 0.05706339097770921, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9814589803375031}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.94}, {&quot;x&quot;: 0.03526711513754839, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.048541019662497}, {&quot;x&quot;: -0.03526711513754838, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.048541019662497}, {&quot;x&quot;: -0.05706339097770922, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 0.9814589803375031}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.8200000000000003, &quot;z&quot;: 1.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.019021130325903, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.006180339887498899}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.019999999999999952}, {&quot;x&quot;: 4.011755705045849, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.016180339887498996}, {&quot;x&quot;: 3.9882442949541503, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.016180339887499}, {&quot;x&quot;: 3.980978869674097, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.006180339887498895}, {&quot;x&quot;: 4.019021130325903, &quot;y&quot;: 3.7843667304341507e-19, &quot;z&quot;: -0.006180339887498949}, {&quot;x&quot;: 4.0, &quot;y&quot;: 1.2246467991473532e-18, &quot;z&quot;: -0.02}, {&quot;x&quot;: 4.011755705045849, &quot;y&quot;: -9.907600726170915e-19, &quot;z&quot;: 0.016180339887498948}, {&quot;x&quot;: 3.9882442949541503, &quot;y&quot;: -9.907600726170917e-19, &quot;z&quot;: 0.01618033988749895}, {&quot;x&quot;: 3.980978869674097, &quot;y&quot;: 3.784366730434148e-19, &quot;z&quot;: -0.006180339887498945}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 4.0, &quot;y&quot;: 1.0, &quot;z&quot;: 6.123233995736767e-17}, {&quot;x&quot;: 4.057063390977709, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.0185410196624968}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.05999999999999995}, {&quot;x&quot;: 4.0352671151375485, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.04854101966249689}, {&quot;x&quot;: 3.9647328848624515, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 0.0485410196624969}, {&quot;x&quot;: 3.942936609022291, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: -0.018541019662496785}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.8200000000000001, &quot;z&quot;: 5.021051876504149e-17}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 4.82, &quot;y&quot;: 0.0, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: -0.019021130325903024}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.02, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: -0.011755705045849415}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 0.011755705045849512}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 0.01902113032590312}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.006180339887498949, &quot;z&quot;: -0.019021130325903073}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.02, &quot;z&quot;: 0.0}, {&quot;x&quot;: 4.0, &quot;y&quot;: -0.016180339887498948, &quot;z&quot;: -0.011755705045849465}, {&quot;x&quot;: 4.0, &quot;y&quot;: -0.01618033988749895, &quot;z&quot;: 0.011755705045849461}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.006180339887498945, &quot;z&quot;: 0.019021130325903073}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6, 7], [1, 3, 8, 6], [3, 4, 9, 8], [4, 5, 10, 9], [5, 2, 7, 10], [7, 6, 11], [6, 8, 11], [8, 9, 11], [9, 10, 11], [10, 7, 11]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 5.0, &quot;y&quot;: 0.0, &quot;z&quot;: 6.123233995736767e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.018541019662496848, &quot;z&quot;: -0.05706339097770916}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.06, &quot;z&quot;: 5.021051876504149e-17}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.04854101966249684, &quot;z&quot;: -0.03526711513754834}, {&quot;x&quot;: 4.82, &quot;y&quot;: -0.048541019662496854, &quot;z&quot;: 0.035267115137548426}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.018541019662496834, &quot;z&quot;: 0.057063390977709266}, {&quot;x&quot;: 4.82, &quot;y&quot;: 0.0, &quot;z&quot;: 5.021051876504149e-17}], &quot;faces&quot;: [[0, 1, 2], [0, 3, 1], [0, 4, 3], [0, 5, 4], [0, 2, 5], [2, 1, 6], [1, 3, 6], [3, 4, 6], [4, 5, 6], [5, 2, 6]], &quot;color&quot;: &quot;#0000ff&quot;, &quot;opacity&quot;: 1.0, &quot;linewidth&quot;: 1.0}, {&quot;vertices&quot;: [{&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 3.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 2.0, &quot;z&quot;: 1.0}, {&quot;x&quot;: 4.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}, {&quot;x&quot;: 2.0, &quot;y&quot;: 0.0, &quot;z&quot;: 1.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 0.0, &quot;z&quot;: 4.0}, {&quot;x&quot;: 0.0, &quot;y&quot;: 3.0, &quot;z&quot;: 1.0}, {&quot;x&quot;: 4.0, &quot;y&quot;: 1.0, &quot;z&quot;: 0.0}, {&quot;x&quot;: 5.0, &quot;y&quot;: 0.0, &quot;z&quot;: 0.0}], &quot;faces&quot;: [[7, 2, 3, 0, 4], [3, 0, 1], [4, 0, 1, 5], [2, 6, 5, 1], [6, 2, 7], [3, 1, 2]], &quot;color&quot;: &quot;#008000&quot;, &quot;opacity&quot;: 1.0, &quot;useFlatShading&quot;: true}];\n",
" for ( var i=0 ; i &lt; surfaces.length ; i++ ) addSurface( surfaces[i] );\n",
"\n",
" function addSurface( json ) {\n",
"\n",
" var useFaceColors = &#x27;faceColors&#x27; in json ? true : false;\n",
"\n",
" var geometry = new THREE.Geometry();\n",
" for ( var i=0 ; i &lt; json.vertices.length ; i++ ) {\n",
" var v = json.vertices[i];\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v.x, a[1]*v.y, a[2]*v.z ) );\n",
" }\n",
" for ( var i=0 ; i &lt; json.faces.length ; i++ ) {\n",
" var f = json.faces[i];\n",
" for ( var j=0 ; j &lt; f.length - 2 ; j++ ) {\n",
" var face = new THREE.Face3( f[0], f[j+1], f[j+2] );\n",
" if ( useFaceColors ) face.color.set( json.faceColors[i] );\n",
" geometry.faces.push( face );\n",
" }\n",
" }\n",
" geometry.computeVertexNormals();\n",
"\n",
" var side = json.singleSide ? THREE.FrontSide : THREE.DoubleSide;\n",
" var transparent = json.opacity &lt; 1 ? true : false;\n",
" var depthWrite = &#x27;depthWrite&#x27; in json ? json.depthWrite : !transparent;\n",
" var flatShading = json.useFlatShading ? json.useFlatShading : false;\n",
"\n",
" var material = new THREE.MeshPhongMaterial( { side: side,\n",
" color: useFaceColors ? &#x27;white&#x27; : json.color,\n",
" vertexColors: useFaceColors ? THREE.FaceColors : THREE.NoColors,\n",
" transparent: transparent, opacity: json.opacity,\n",
" shininess: 20, flatShading: flatShading,\n",
" depthWrite: depthWrite } );\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var mesh = new THREE.Mesh( geometry, material );\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" if ( transparent &amp;&amp; json.renderOrder ) mesh.renderOrder = json.renderOrder;\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" if ( json.showMeshGrid ) addSurfaceMeshGrid( json );\n",
"\n",
" }\n",
"\n",
" function addSurfaceMeshGrid( json ) {\n",
"\n",
" var geometry = new THREE.Geometry();\n",
"\n",
" for ( var i=0 ; i &lt; json.faces.length ; i++ ) {\n",
" var f = json.faces[i];\n",
" for ( var j=0 ; j &lt; f.length ; j++ ) {\n",
" var k = j === f.length-1 ? 0 : j+1;\n",
" var v1 = json.vertices[f[j]];\n",
" var v2 = json.vertices[f[k]];\n",
" // vertices in opposite directions on neighboring faces\n",
" var nudge = f[j] &lt; f[k] ? .0005*zRange : -.0005*zRange;\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v1.x, a[1]*v1.y, a[2]*(v1.z+nudge) ) );\n",
" geometry.vertices.push( new THREE.Vector3( a[0]*v2.x, a[1]*v2.y, a[2]*(v2.z+nudge) ) );\n",
" }\n",
" }\n",
"\n",
" var c = new THREE.Vector3();\n",
" geometry.computeBoundingBox();\n",
" geometry.boundingBox.getCenter( c );\n",
" geometry.translate( -c.x, -c.y, -c.z );\n",
"\n",
" var gridColor = options.theme === &#x27;dark&#x27; ? &#x27;white&#x27; : &#x27;black&#x27;;\n",
" var linewidth = json.linewidth || 1;\n",
" var materialOptions = { color: gridColor, linewidth: linewidth };\n",
"\n",
" var mesh;\n",
" if ( linewidth &gt; 1 &amp;&amp; window.createFatLineSegments ) {\n",
" mesh = createFatLineSegments( geometry, materialOptions );\n",
" } else {\n",
" var material = new THREE.LineBasicMaterial( materialOptions );\n",
" mesh = new THREE.LineSegments( geometry, material );\n",
" }\n",
"\n",
" mesh.position.set( c.x, c.y, c.z );\n",
" mesh.userData = json;\n",
" scene.add( mesh );\n",
"\n",
" }\n",
"\n",
" function render() {\n",
"\n",
" if ( window.updateAnimation ) animate = updateAnimation();\n",
" if ( animate ) requestAnimationFrame( render );\n",
"\n",
" renderer.render( scene, camera );\n",
"\n",
" }\n",
"\n",
" render();\n",
" controls.update();\n",
" if ( !animate ) render();\n",
"\n",
"\n",
" // menu functions\n",
"\n",
" function toggleMenu() {\n",
"\n",
" var m = document.getElementById( &#x27;menu-content&#x27; );\n",
" if ( m.style.display === &#x27;block&#x27; ) m.style.display = &#x27;none&#x27;\n",
" else m.style.display = &#x27;block&#x27;;\n",
"\n",
" }\n",
"\n",
"\n",
" function saveAsPNG() {\n",
"\n",
" var a = document.body.appendChild( document.createElement( &#x27;a&#x27; ) );\n",
" a.href = renderer.domElement.toDataURL( &#x27;image/png&#x27; );\n",
" a.download = &#x27;screenshot&#x27;;\n",
" a.click();\n",
"\n",
" }\n",
"\n",
" function saveAsHTML() {\n",
"\n",
" toggleMenu(); // otherwise visible in output\n",
" event.stopPropagation();\n",
"\n",
" var blob = new Blob( [ &#x27;&lt;!DOCTYPE html&gt;\\n&#x27; + document.documentElement.outerHTML ] );\n",
" var a = document.body.appendChild( document.createElement( &#x27;a&#x27; ) );\n",
" a.href = window.URL.createObjectURL( blob );\n",
" a.download = suggestFilename();\n",
" a.click();\n",
"\n",
" function suggestFilename() {\n",
" if ( !document.title ) {\n",
" return &#x27;graphic.html&#x27;;\n",
" } else if ( /\\.html?$/i.test( document.title ) ) {\n",
" return document.title; // already ends in .htm or .html\n",
" } else {\n",
" return document.title + &#x27;.html&#x27;;\n",
" }\n",
" }\n",
"\n",
" }\n",
"\n",
" function getViewpoint() {\n",
"\n",
" function roundTo( x, n ) { return +x.toFixed(n); }\n",
"\n",
" var v = camera.quaternion.inverse();\n",
" var r = Math.sqrt( v.x*v.x + v.y*v.y + v.z*v.z );\n",
" var axis = [ roundTo( v.x / r, 4 ), roundTo( v.y / r, 4 ), roundTo( v.z / r, 4 ) ];\n",
" var angle = roundTo( 2 * Math.atan2( r, v.w ) * 180 / Math.PI, 2 );\n",
"\n",
" var textArea = document.createElement( &#x27;textarea&#x27; );\n",
" textArea.textContent = JSON.stringify( axis ) + &#x27;,&#x27; + angle;\n",
" textArea.style.csstext = &#x27;position: absolute; top: -100%&#x27;;\n",
" document.body.append( textArea );\n",
" textArea.select();\n",
" document.execCommand( &#x27;copy&#x27; );\n",
"\n",
" var m = document.getElementById( &#x27;menu-message&#x27; );\n",
" m.innerHTML = &#x27;Viewpoint copied to clipboard&#x27;;\n",
" m.style.display = &#x27;block&#x27;;\n",
" setTimeout( function() { m.style.display = &#x27;none&#x27;; }, 2000 );\n",
"\n",
" }\n",
"\n",
" function getCamera() {\n",
"\n",
" function roundTo( x, n ) { return +x.toFixed(n); }\n",
"\n",
" var pos = camera.position;\n",
" var pos_r = [ roundTo( pos.x, 4 ), roundTo( pos.y, 4 ), roundTo( pos.z, 4 ) ];\n",
" // var up = camera.up; // up is always (0,0,1)\n",
" var textArea = document.createElement(&#x27;textarea&#x27;);\n",
" var cam_position = JSON.stringify(pos_r);\n",
" textArea.textContent = &#x27;,camera_position=&#x27; + cam_position;\n",
" textArea.style.csstext = &#x27;position: absolute; top: -100%&#x27;;\n",
" document.body.append( textArea );\n",
" textArea.select();\n",
" document.execCommand( &#x27;copy&#x27; );\n",
"\n",
" var m = document.getElementById( &#x27;menu-message&#x27; );\n",
" m.innerHTML = &#x27;Camera position &#x27;+ cam_position+&#x27; copied to clipboard&#x27;;\n",
" m.style.display = &#x27;block&#x27;;\n",
" setTimeout( function() { m.style.display = &#x27;none&#x27;; }, 2000 );\n",
"\n",
" }\n",
"\n",
"&lt;/script&gt;\n",
"\n",
"&lt;div id=&quot;menu-container&quot; onclick=&quot;toggleMenu()&quot;&gt;&amp;#x24d8;\n",
"&lt;div id=&quot;menu-message&quot;&gt;&lt;/div&gt;\n",
"&lt;div id=&quot;menu-content&quot;&gt;\n",
"&lt;div onclick=&quot;saveAsPNG()&quot;&gt;Save as PNG&lt;/div&gt;\n",
"&lt;div onclick=&quot;saveAsHTML()&quot;&gt;Save as HTML&lt;/div&gt;\n",
"&lt;div onclick=&quot;getCamera()&quot;&gt;Get camera&lt;/div&gt;\n",
"&lt;div onclick=&quot;getViewpoint()&quot;&gt;Get viewpoint&lt;/div&gt;\n",
"&lt;div&gt;Close Menu&lt;/div&gt;\n",
"&lt;/div&gt;&lt;/div&gt;\n",
"\n",
"\n",
"&lt;/body&gt;\n",
"&lt;/html&gt;\n",
"\"\n",
" width=\"100%\"\n",
" height=\"400\"\n",
" style=\"border: 0;\">\n",
"</iframe>\n"
],
"text/plain": [
"Graphics3d Object"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Zt.newton_plot()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "974b2099-0fdb-42b4-829b-72b6e0a7b38b",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Newton's polyhedron of z^3 - 3*y^2*z + 3*x^2*z + 2*x^4:\n",
" support points = [(0, 0, 3), (0, 2, 1), (2, 0, 1), (4, 0, 0)]\n",
" vertices = [(0, 0, 3), (0, 2, 1), (2, 0, 1), (4, 0, 0)]\n",
" number of compact faces = 11\n",
" Facet 1: -4 + 2*z + y + x >= 0\n",
" Facet 4: -3 + z + y + x >= 0\n"
]
}
],
"source": [
"Z.give_info_newton(compact=True)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "7a653a38-c2f6-45e5-bf44-81173d1ede55",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Newton's polyhedron of z^3 - 3*y^2*z + t*x*z^2 + 3*x^2*z + 2*x^4:\n",
" support points = [(0, 0, 3), (0, 2, 1), (1, 0, 2), (2, 0, 1), (4, 0, 0)]\n",
" vertices = [(0, 0, 3), (0, 2, 1), (4, 0, 0), (2, 0, 1)]\n",
" number of compact faces = 11\n",
" Facet 0: -4 + 2*z + y + x >= 0\n",
" Facet 4: -3 + z + y + x >= 0\n"
]
}
],
"source": [
"Zt.give_info_newton(compact=True)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "448680b0-7998-4c7a-a400-f44bbed407bb",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"z^3 - 3*y^2*z + t*x*z^2 + 3*x^2*z + 2*x^4"
]
},
"execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Ft"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "05705617-d0f6-464a-a9a0-4cefb5bce4d1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"u^14 * (2*v + v^2 + u^3 + u^3*v)"
]
},
"execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nwt(f).factor()"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "4eb24e43-3a10-4db9-8502-8c62289a3fe7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"u^24 * (1 + 6*u^3 + 6*u^3*v + 4*u^4*v^2 + 4*u^4*v^3 + u^4*v^4 + 15*u^6 + 30*u^6*v + 15*u^6*v^2 + 4*u^7*v + 6*u^7*v^2 + 2*u^7*v^3 + 20*u^9 + 60*u^9*v + 60*u^9*v^2 + 20*u^9*v^3 + u^10 + 2*u^10*v + u^10*v^2 + 15*u^12 + 60*u^12*v + 90*u^12*v^2 + 60*u^12*v^3 + 15*u^12*v^4 + 6*u^15 + 30*u^15*v + 60*u^15*v^2 + 60*u^15*v^3 + 30*u^15*v^4 + 6*u^15*v^5 + u^18 + 6*u^18*v + 15*u^18*v^2 + 20*u^18*v^3 + 15*u^18*v^4 + 6*u^18*v^5 + u^18*v^6)"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nwt(g).factor()"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "28776340-947d-4ed6-a492-79f9341b9f18",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1 + v)^2 * u^14"
]
},
"execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nwt(f2).factor()"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "358b6044-7de1-4bfe-9e4f-283adfc93aca",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(3/2) * (1 + v) * u^21 * (2*v + v^2 + u^3 + u^3*v)"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nwt(g1).factor()"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "cda085bf-987d-44c2-8dbd-ae21afaa3251",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(1 + v)^3 * u^21"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"nwt(g3).factor()"
]
},
{
"cell_type": "code",
"execution_count": 41,
"id": "9684ce50-7ff0-4b4c-9580-497c3e3b3964",
"metadata": {},
"outputs": [],
"source": [
"h1 = F1.discriminant(z)(x=u, y=v)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "220532f1-226a-4898-9ff8-5f0344a7de16",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(-27) * (v^2 - u^7) * (3965*v^4 + 2735*u^7*v^2 + 2048*u^14)]"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Z1 = ZetaFunctions(h1)\n",
"[q.factor() for q in Z1.get_polyfaces_dictionary(compact=True) if q.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "17c661cd-7293-41a1-b9ec-2e71269ae582",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[(108) * u^21 * (3*v^2 - 2*u^3)]"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"h1a = S(h1(u=u^2, v=u^7 * (1 + v)) / u^21)\n",
"Z1a = ZetaFunctions(h1a)\n",
"[q.factor() for q in Z1a.get_polyfaces_dictionary(compact=True) if q.number_of_terms() > 1]"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "aa670fe5-7aa2-4b88-9e85-4351e528b2a1",
"metadata": {},
"outputs": [],
"source": [
"Rt.<x, y, z, t> = QQ[]\n",
"Ft = Rt(F - 3 * f2(u=x, v=y) * t^2 * z + 2 * g1(u=x, v=y) * t + 2 * g3(u=x, v=y) * t^3)"
]
},
{
"cell_type": "code",
"execution_count": 58,
"id": "198a37ca-5a9d-4fe4-8949-e9ca06d48119",
"metadata": {},
"outputs": [],
"source": [
"J = Rt.ideal([Ft.derivative(a) for a in Rt.gens()[:-1]] + [Ft])"
]
},
{
"cell_type": "code",
"execution_count": 66,
"id": "77792a73-db8e-43a5-93b7-dacb75f92c4f",
"metadata": {},
"outputs": [],
"source": [
"Gt = Ft(z=z + y * t)"
]
},
{
"cell_type": "code",
"execution_count": 67,
"id": "18ec2301-7665-436a-9a9c-e1070d99dfd1",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"3*y*z^2"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"Gt.derivative(t)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0fa40cb1-67c3-40c4-bf4b-60dd202979d2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 10.5.beta3",
"language": "sage",
"name": "sagemath-devel"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}