diff --git a/pyzx/js/zx_viewer3d.js b/pyzx/js/zx_viewer3d.js index ad94b339..6b72d679 100644 --- a/pyzx/js/zx_viewer3d.js +++ b/pyzx/js/zx_viewer3d.js @@ -39,7 +39,7 @@ export function showGraph3D(tag, graph, width, height, show_labels) { const controls = new OrbitControls( camera, labelRenderer.domElement ); controls.minDistance = 1; controls.maxDistance = 100; - controls.enablePan = false; + // controls.enablePan = false; scene.add(new THREE.AmbientLight(0xffffff, 1.5)); const light = new THREE.DirectionalLight( 0xffffff, 2); light.position.set(1, 1, 1).normalize(); @@ -55,10 +55,10 @@ export function showGraph3D(tag, graph, width, height, show_labels) { let color = 0x000000, radius = 0.1; if (d.t == 1) { color = Number('0x' + '#99dd99'.substring(1)); - radius = 0.2; + radius = 0.15; } else if (d.t == 2) { color = Number('0x' + '#ff8888'.substring(1)); - radius = 0.2; + radius = 0.15; } const geometry = new THREE.SphereGeometry(radius, 48, 24); @@ -92,8 +92,16 @@ export function showGraph3D(tag, graph, width, height, show_labels) { // s.nhd.push(t); // t.nhd.push(s); let color = 0x000000; - if (s.x != t.x) { - color = 0x999999; + if (d.t == 2) { + if (s.x != t.x) { + color = 0xffff99; + } else { + color = 0xffff66; + } + } else { + if (s.x != t.x) { + color = 0x999999; + } } const material = new LineMaterial({ color: color, linewidth: 2 }); diff --git a/scratchpads/ak.ipynb b/scratchpads/ak.ipynb index 1122ebd4..b1e555ef 100644 --- a/scratchpads/ak.ipynb +++ b/scratchpads/ak.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -24,22 +24,19 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "metadata": {}, "outputs": [], "source": [ - "def unmap_grid(p, width):\n", + "def unmap_qubit(p, width):\n", " y,z = p\n", " return y + z*width\n", "\n", - "def map_grid(q, width):\n", - " z = math.floor(q/width)\n", - " y = q - z*width\n", - " return (y,z)\n", - "\n", "def map_qubits(g, width):\n", " for v in g.vertices():\n", - " y,z = map_grid(g.qubit(v), width)\n", + " q = g.qubit(v)\n", + " z = math.floor(q/width)\n", + " y = q - z*width\n", " g.set_qubit(v, y)\n", " g.set_vdata(v, 'z', z)\n", "\n", @@ -51,15 +48,23 @@ " q = (random.randint(0,height-1), random.randint(0,width-1))\n", " ns = [(q[0]-1, q[1]), (q[0]+1, q[1]), (q[0], q[1]-1), (q[0], q[1]+1)]\n", " q1 = random.choice([(y,z) for y,z in ns if y >= 0 and y < height and z >= 0 and z < width])\n", - " c.add_gate('CNOT', unmap_grid(q, width), unmap_grid(q1, width))\n", + " c.add_gate('CNOT', unmap_qubit(q, width), unmap_qubit(q1, width))\n", " return c" ] }, { "cell_type": "code", - "execution_count": null, + "execution_count": 3, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[CNOT(8,5), CNOT(8,7), CNOT(4,1), CNOT(4,5), CNOT(5,4), CNOT(7,8), CNOT(6,3), CNOT(4,1), CNOT(2,5), CNOT(2,5), CNOT(0,3), CNOT(8,5), CNOT(5,4), CNOT(2,1), CNOT(3,6), CNOT(2,1), CNOT(2,1), CNOT(3,4), CNOT(7,4), CNOT(1,4)]\n" + ] + } + ], "source": [ "qubits = 9\n", "width = 3\n", @@ -74,9 +79,153 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 4, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/html": [ + "\n", + "
\n", + " \n", + " \n", + " " + ], + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ "zx.draw_3d(g)" ]