let currentMoleculeKey = null; let atoms = []; let bonds = []; let rotX = 0, rotY = 0, panX = 0, panY = 0, zoom = 1.0; let lastX = 0, lastY = 0, isDragging = false; let isRotating = true, showLabels = true, autoRotationAngle = 0; let myFont; let touchesStart = []; let initialZoom = 1.0; let initialPanX = 0, initialPanY = 0; let initialDist = 0; let currentLang = 'vi'; // Tăng SCALE lên 85 để không gian rộng rãi, các nguyên tử không bị đè vào nhau const SCALE = 85; const TRANSLATIONS = { vi: { headerTitle: "CẤU TRÚC PHÂN TỬ 3D", headerSub: "HÓA HỌC ABC", placeholder: "-- Chọn phân tử --", canvasMsg: "Vui lòng chọn phân tử từ menu", btnRotate: "Xoay Tự Động", btnLabels: "Nhãn Nguyên Tố", btnSave: "Lưu Ảnh", resCurrent: "Màn hình hiện tại", fmtPNG: "PNG", fmtJPG: "JPG", optgroups: { "opt-inorganic":"Chất vô cơ","opt-hydrocarbons":"Hiđrocacbon", "opt-halogen":"Dẫn xuất Halogen","opt-alcohols":"Ancol & Phenol", "opt-aldehydes":"Anđehit & Xeton","opt-acids":"Axit Cacboxylic", "opt-esters":"Este","opt-amines":"Amin & Hợp chất vòng", "opt-carbs":"Cacbohiđrat","opt-amino-acids":"Amino Acids" } }, en: { headerTitle: "3D MOLECULAR STRUCTURE", headerSub: "HÓA HỌC ABC", placeholder: "-- Select Molecule --", canvasMsg: "Please select a molecule from the menu", btnRotate: "Auto Rotate", btnLabels: "Atom Labels", btnSave: "Save Image", resCurrent: "Current Viewport", fmtPNG: "PNG", fmtJPG: "JPG", optgroups: { "opt-inorganic":"Inorganic substances","opt-hydrocarbons":"Hydrocarbons", "opt-halogen":"Halogen derivatives","opt-alcohols":"Alcohols & Phenols", "opt-aldehydes":"Aldehydes & Ketones","opt-acids":"Carboxylic acids", "opt-esters":"Esters","opt-amines":"Amines & Heterocyclics", "opt-carbs":"Carbohydrates","opt-amino-acids":"Amino Acids" } } }; const ELEMENTS = { H: { color:[255,255,255], radius:18, textColor:[0,0,0] }, C: { color:[90,90,90], radius:32, textColor:[255,255,255] }, N: { color:[48,80,248], radius:32, textColor:[255,255,255] }, O: { color:[255,13,13], radius:28, textColor:[255,255,255] }, F: { color:[144,224,80], radius:30, textColor:[0,0,0] }, Cl: { color:[31,240,31], radius:38, textColor:[0,0,0] }, S: { color:[255,255,48], radius:36, textColor:[0,0,0] }, P: { color:[255,128,0], radius:36, textColor:[0,0,0] } }; const SINGLE_RING_AROMATIC = [ "C6H6","C6H5CH3","ethylbenzene","o_xylene","m_xylene","p_xylene", "styrene","C6H5OH","C6H5NH2","benzoic_acid", "pyridine", "aspirin" ]; const DOUBLE_RING_AROMATIC = ["naphthalene"]; // ===================================================================== // DATA CÁC CHẤT // ===================================================================== const MOLECULE_DATA = { // --- VÔ CƠ --- "H2": { atoms:[{e:"H",x:-0.37,y:0,z:0},{e:"H",x:0.37,y:0,z:0}], bonds:[[0,1,1]] }, "N2": { atoms:[{e:"N",x:-0.55,y:0,z:0},{e:"N",x:0.55,y:0,z:0}], bonds:[[0,1,3]] }, "O2": { atoms:[{e:"O",x:-0.6,y:0,z:0},{e:"O",x:0.6,y:0,z:0}], bonds:[[0,1,2]] }, "O3": { atoms:[{e:"O",x:0,y:0.4,z:0},{e:"O",x:-1.1,y:-0.2,z:0},{e:"O",x:1.1,y:-0.2,z:0}], bonds:[[0,1,2],[0,2,1]] }, "F2": { atoms:[{e:"F",x:-0.55,y:0,z:0},{e:"F",x:0.55,y:0,z:0}], bonds:[[0,1,1]] }, "Cl2": { atoms:[{e:"Cl",x:-0.8,y:0,z:0},{e:"Cl",x:0.8,y:0,z:0}], bonds:[[0,1,1]] }, "CO": { atoms:[{e:"C",x:-0.5,y:0,z:0},{e:"O",x:0.6,y:0,z:0}], bonds:[[0,1,3]] }, "CO2": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:-1.16,y:0,z:0},{e:"O",x:1.16,y:0,z:0}], bonds:[[0,1,2],[0,2,2]] }, "SO2": { atoms:[{e:"S",x:0,y:0.3,z:0},{e:"O",x:-1.25,y:-0.5,z:0},{e:"O",x:1.25,y:-0.5,z:0}], bonds:[[0,1,2],[0,2,2]] }, "SO3": { atoms:[{e:"S",x:0,y:0,z:0},{e:"O",x:0,y:1.4,z:0},{e:"O",x:1.21,y:-0.7,z:0},{e:"O",x:-1.21,y:-0.7,z:0}], bonds:[[0,1,2],[0,2,2],[0,3,2]] }, "HCl": { atoms:[{e:"H",x:-0.64,y:0,z:0},{e:"Cl",x:0.64,y:0,z:0}], bonds:[[0,1,1]] }, "H2O": { atoms:[{e:"O",x:0,y:0.15,z:0},{e:"H",x:0.76,y:-0.45,z:0},{e:"H",x:-0.76,y:-0.45,z:0}], bonds:[[0,1,1],[0,2,1]] }, "H2O2": { atoms:[{e:"O",x:-0.7,y:0,z:0.3},{e:"O",x:0.7,y:0,z:-0.3},{e:"H",x:-1.1,y:0.8,z:-0.1},{e:"H",x:1.1,y:-0.8,z:0.1}], bonds:[[0,1,1],[0,2,1],[1,3,1]] }, "H2S": { atoms:[{e:"S",x:0,y:0.2,z:0},{e:"H",x:0.85,y:-0.65,z:0},{e:"H",x:-0.85,y:-0.65,z:0}], bonds:[[0,1,1],[0,2,1]] }, "NH3": { atoms:[ {e:"N",x:0.000,y:0.000,z:0.000}, {e:"H",x:0.000,y:-0.380,z:0.930}, {e:"H",x:0.805,y:-0.380,z:-0.465}, {e:"H",x:-0.805,y:-0.380,z:-0.465} ], bonds:[[0,1,1],[0,2,1],[0,3,1]] }, "H2SO4": { atoms:[{e:"S",x:0,y:0,z:0},{e:"O",x:0.87,y:0.87,z:0.87},{e:"O",x:-0.87,y:-0.87,z:0.87}, {e:"O",x:0.87,y:-0.87,z:-0.87},{e:"O",x:-0.87,y:0.87,z:-0.87}, {e:"H",x:1.2,y:-1.6,z:-0.3},{e:"H",x:-1.2,y:1.6,z:-0.3}], bonds:[[0,1,2],[0,2,2],[0,3,1],[0,4,1],[3,5,1],[4,6,1]] }, "HNO3": { atoms:[ {e:"N",x:0.000,y:0.000,z:0}, {e:"O",x:1.220,y:0.000,z:0}, {e:"O",x:-0.610,y:1.057,z:0}, {e:"O",x:-0.610,y:-1.057,z:0}, {e:"H",x:-1.570,y:1.057,z:0} ], bonds:[[0,1,2],[0,2,1],[0,3,2],[2,4,1]] }, "H3PO4": { atoms:[{e:"P",x:0,y:0,z:0},{e:"O",x:0,y:1.45,z:0},{e:"O",x:1.2,y:-0.5,z:0.5}, {e:"O",x:-1.2,y:-0.5,z:0.5},{e:"O",x:0,y:-0.5,z:-1.3}, {e:"H",x:1.6,y:0.3,z:0.9},{e:"H",x:-1.6,y:0.3,z:0.9},{e:"H",x:0,y:0.3,z:-2.0}], bonds:[[0,1,2],[0,2,1],[0,3,1],[0,4,1],[2,5,1],[3,6,1],[4,7,1]] }, // --- HYDROCARBONS --- "CH4": { atoms:[{e:"C",x:0,y:0,z:0},{e:"H",x:0.63,y:0.63,z:0.63},{e:"H",x:-0.63,y:-0.63,z:0.63}, {e:"H",x:-0.63,y:0.63,z:-0.63},{e:"H",x:0.63,y:-0.63,z:-0.63}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1]] }, "C2H6": { atoms:[{e:"C",x:-0.76,y:0,z:0},{e:"C",x:0.76,y:0,z:0},{e:"H",x:-1.1,y:1.0,z:0}, {e:"H",x:-1.1,y:-0.5,z:0.87},{e:"H",x:-1.1,y:-0.5,z:-0.87},{e:"H",x:1.1,y:-1.0,z:0}, {e:"H",x:1.1,y:0.5,z:-0.87},{e:"H",x:1.1,y:0.5,z:0.87}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[1,7,1]] }, "C3H8": { atoms:[{e:"C",x:0,y:0.4,z:0},{e:"C",x:-1.4,y:-0.4,z:0},{e:"C",x:1.4,y:-0.4,z:0}, {e:"H",x:0,y:0.9,z:0.88},{e:"H",x:0,y:0.9,z:-0.88},{e:"H",x:-1.4,y:-1.5,z:0}, {e:"H",x:-1.9,y:-0.05,z:0.88},{e:"H",x:-1.9,y:-0.05,z:-0.88},{e:"H",x:1.4,y:-1.5,z:0}, {e:"H",x:1.9,y:-0.05,z:0.88},{e:"H",x:1.9,y:-0.05,z:-0.88}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[1,7,1],[2,8,1],[2,9,1],[2,10,1]] }, "nC4H10": { atoms:[{e:"C",x:-2.1,y:-0.4,z:0},{e:"C",x:-0.7,y:0.4,z:0},{e:"C",x:0.7,y:-0.4,z:0},{e:"C",x:2.1,y:0.4,z:0}, {e:"H",x:-2.1,y:-1.5,z:0},{e:"H",x:-2.6,y:-0.05,z:0.88},{e:"H",x:-2.6,y:-0.05,z:-0.88}, {e:"H",x:-0.7,y:0.9,z:0.88},{e:"H",x:-0.7,y:0.9,z:-0.88},{e:"H",x:0.7,y:-0.9,z:0.88}, {e:"H",x:0.7,y:-0.9,z:-0.88},{e:"H",x:2.1,y:1.5,z:0},{e:"H",x:2.6,y:0.05,z:0.88},{e:"H",x:2.6,y:0.05,z:-0.88}], bonds:[[0,1,1],[1,2,1],[2,3,1],[0,4,1],[0,5,1],[0,6,1],[1,7,1],[1,8,1],[2,9,1],[2,10,1],[3,11,1],[3,12,1],[3,13,1]] }, "isoC4H10": { atoms:[{e:"C",x:0,y:0,z:0},{e:"H",x:0,y:0,z:1.1},{e:"C",x:0,y:1.4,z:-0.5},{e:"C",x:1.2,y:-0.7,z:-0.5},{e:"C",x:-1.2,y:-0.7,z:-0.5}, {e:"H",x:0,y:1.5,z:-1.6},{e:"H",x:0.9,y:1.9,z:-0.1},{e:"H",x:-0.9,y:1.9,z:-0.1}, {e:"H",x:1.3,y:-0.7,z:-1.6},{e:"H",x:2.1,y:-0.3,z:-0.1},{e:"H",x:1.3,y:-1.7,z:-0.1}, {e:"H",x:-1.3,y:-0.7,z:-1.6},{e:"H",x:-2.1,y:-0.3,z:-0.1},{e:"H",x:-1.3,y:-1.7,z:-0.1}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[2,5,1],[2,6,1],[2,7,1],[3,8,1],[3,9,1],[3,10,1],[4,11,1],[4,12,1],[4,13,1]] }, "C2H4": { atoms:[{e:"C",x:-0.67,y:0,z:0},{e:"C",x:0.67,y:0,z:0},{e:"H",x:-1.25,y:0.92,z:0}, {e:"H",x:-1.25,y:-0.92,z:0},{e:"H",x:1.25,y:0.92,z:0},{e:"H",x:1.25,y:-0.92,z:0}], bonds:[[0,1,2],[0,2,1],[0,3,1],[1,4,1],[1,5,1]] }, "C2H2": { atoms:[{e:"C",x:-0.6,y:0,z:0},{e:"C",x:0.6,y:0,z:0},{e:"H",x:-1.66,y:0,z:0},{e:"H",x:1.66,y:0,z:0}], bonds:[[0,1,3],[0,2,1],[1,3,1]] }, "C3H6_open": { atoms:[{e:"C",x:-1.2,y:-0.3,z:0},{e:"C",x:0,y:0.4,z:0},{e:"C",x:1.3,y:-0.1,z:0}, {e:"H",x:-1.2,y:-1.4,z:0},{e:"H",x:-2.1,y:0.2,z:0},{e:"H",x:0,y:1.5,z:0}, {e:"H",x:1.3,y:-1.2,z:0},{e:"H",x:1.9,y:0.3,z:0.9},{e:"H",x:1.9,y:0.3,z:-0.9}], bonds:[[0,1,2],[1,2,1],[0,3,1],[0,4,1],[1,5,1],[2,6,1],[2,7,1],[2,8,1]] }, "C3H6_ring": { atoms:[{e:"C",x:0,y:1.0,z:0},{e:"C",x:0.87,y:-0.5,z:0},{e:"C",x:-0.87,y:-0.5,z:0}, {e:"H",x:0,y:1.3,z:0.9},{e:"H",x:0,y:1.3,z:-0.9},{e:"H",x:1.1,y:-0.7,z:0.9}, {e:"H",x:1.1,y:-0.7,z:-0.9},{e:"H",x:-1.1,y:-0.7,z:0.9},{e:"H",x:-1.1,y:-0.7,z:-0.9}], bonds:[[0,1,1],[1,2,1],[2,0,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[2,7,1],[2,8,1]] }, "cyclohexane": { atoms:[ {e:"C",x:1.2,y:-0.7,z:0.3},{e:"C",x:1.2,y:0.7,z:-0.3},{e:"C",x:0.0,y:1.4,z:0.3}, {e:"C",x:-1.2,y:0.7,z:-0.3},{e:"C",x:-1.2,y:-0.7,z:0.3},{e:"C",x:0.0,y:-1.4,z:-0.3}, {e:"H",x:2.1,y:-1.1,z:-0.2},{e:"H",x:1.2,y:-0.7,z:1.4},{e:"H",x:2.1,y:1.1,z:0.2}, {e:"H",x:1.2,y:0.7,z:-1.4},{e:"H",x:0.0,y:2.5,z:-0.2},{e:"H",x:0.0,y:1.4,z:1.4}, {e:"H",x:-2.1,y:1.1,z:0.2},{e:"H",x:-1.2,y:0.7,z:-1.4},{e:"H",x:-2.1,y:-1.1,z:-0.2}, {e:"H",x:-1.2,y:-0.7,z:1.4},{e:"H",x:0.0,y:-2.5,z:0.2},{e:"H",x:0.0,y:-1.4,z:-1.4} ], bonds:[ [0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1], [0,6,1],[0,7,1],[1,8,1],[1,9,1],[2,10,1],[2,11,1], [3,12,1],[3,13,1],[4,14,1],[4,15,1],[5,16,1],[5,17,1] ] }, "cis_but_2_ene": { atoms:[{e:"C",x:-0.67,y:0,z:0},{e:"C",x:0.67,y:0,z:0},{e:"C",x:-1.5,y:1.2,z:0},{e:"C",x:1.5,y:1.2,z:0}, {e:"H",x:-1.2,y:-0.9,z:0},{e:"H",x:1.2,y:-0.9,z:0},{e:"H",x:-1.2,y:1.8,z:0.9}, {e:"H",x:-1.2,y:1.8,z:-0.9},{e:"H",x:-2.5,y:0.9,z:0},{e:"H",x:1.2,y:1.8,z:0.9}, {e:"H",x:1.2,y:1.8,z:-0.9},{e:"H",x:2.5,y:0.9,z:0}], bonds:[[0,1,2],[0,2,1],[0,4,1],[1,3,1],[1,5,1],[2,6,1],[2,7,1],[2,8,1],[3,9,1],[3,10,1],[3,11,1]] }, "trans_but_2_ene": { atoms:[{e:"C",x:-0.67,y:0,z:0},{e:"C",x:0.67,y:0,z:0},{e:"C",x:-1.5,y:1.2,z:0},{e:"C",x:1.5,y:-1.2,z:0}, {e:"H",x:-1.2,y:-0.9,z:0},{e:"H",x:1.2,y:0.9,z:0},{e:"H",x:-1.2,y:1.8,z:0.9}, {e:"H",x:-1.2,y:1.8,z:-0.9},{e:"H",x:-2.5,y:0.9,z:0},{e:"H",x:1.2,y:-1.8,z:0.9}, {e:"H",x:1.2,y:-1.8,z:-0.9},{e:"H",x:2.5,y:-0.9,z:0}], bonds:[[0,1,2],[0,2,1],[0,4,1],[1,3,1],[1,5,1],[2,6,1],[2,7,1],[2,8,1],[3,9,1],[3,10,1],[3,11,1]] }, "but_1_3_diene": { atoms:[{e:"C",x:-1.9,y:-0.5,z:0},{e:"C",x:-0.7,y:0.2,z:0},{e:"C",x:0.7,y:-0.2,z:0},{e:"C",x:1.9,y:0.5,z:0}, {e:"H",x:-1.9,y:-1.5,z:0},{e:"H",x:-2.8,y:0.0,z:0},{e:"H",x:-0.7,y:1.2,z:0}, {e:"H",x:0.7,y:-1.2,z:0},{e:"H",x:1.9,y:1.5,z:0},{e:"H",x:2.8,y:0.0,z:0}], bonds:[[0,1,2],[1,2,1],[2,3,2],[0,4,1],[0,5,1],[1,6,1],[2,7,1],[3,8,1],[3,9,1]] }, "isoprene": { atoms:[{e:"C",x:-1.9,y:-0.5,z:0},{e:"C",x:-0.7,y:0.2,z:0},{e:"C",x:0.7,y:-0.2,z:0},{e:"C",x:1.9,y:0.5,z:0}, {e:"C",x:-0.7,y:1.7,z:0},{e:"H",x:-1.9,y:-1.5,z:0},{e:"H",x:-2.8,y:0.0,z:0}, {e:"H",x:0.7,y:-1.2,z:0},{e:"H",x:1.9,y:1.5,z:0},{e:"H",x:2.8,y:0.0,z:0}, {e:"H",x:-1.7,y:2.1,z:0},{e:"H",x:-0.2,y:2.1,z:0.9},{e:"H",x:-0.2,y:2.1,z:-0.9}], bonds:[[0,1,2],[1,2,1],[2,3,2],[1,4,1],[0,5,1],[0,6,1],[2,7,1],[3,8,1],[3,9,1],[4,10,1],[4,11,1],[4,12,1]] }, "C6H6": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"H",x:2.48,y:0,z:0},{e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-1.24,y:2.15,z:0}, {e:"H",x:-2.48,y:0,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[1,7,1],[2,8,1],[3,9,1],[4,10,1],[5,11,1]] }, "C6H5CH3": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"C",x:2.9,y:0,z:0},{e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-1.24,y:2.15,z:0}, {e:"H",x:-2.48,y:0,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"H",x:3.3,y:1.0,z:0},{e:"H",x:3.3,y:-0.5,z:0.87},{e:"H",x:3.3,y:-0.5,z:-0.87}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[1,7,1],[2,8,1],[3,9,1],[4,10,1],[5,11,1],[6,12,1],[6,13,1],[6,14,1]] }, "ethylbenzene": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"C",x:2.9,y:0,z:0},{e:"C",x:3.6,y:1.3,z:0}, {e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0}, {e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"H",x:2.9,y:-0.6,z:0.87},{e:"H",x:2.9,y:-0.6,z:-0.87}, {e:"H",x:4.6,y:1.3,z:0},{e:"H",x:3.3,y:1.9,z:0.87},{e:"H",x:3.3,y:1.9,z:-0.87}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[6,7,1],[1,8,1],[2,9,1],[3,10,1],[4,11,1],[5,12,1],[6,13,1],[6,14,1],[7,15,1],[7,16,1],[7,17,1]] }, "o_xylene": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"C",x:2.9,y:0,z:0},{e:"C",x:1.45,y:2.51,z:0}, {e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"H",x:3.3,y:1.0,z:0},{e:"H",x:3.3,y:-0.5,z:0.87},{e:"H",x:3.3,y:-0.5,z:-0.87}, {e:"H",x:0.78,y:3.35,z:0},{e:"H",x:2.08,y:2.6,z:0.87},{e:"H",x:2.08,y:2.6,z:-0.87}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[1,7,1],[2,8,1],[3,9,1],[4,10,1],[5,11,1],[6,12,1],[6,13,1],[6,14,1],[7,15,1],[7,16,1],[7,17,1]] }, "m_xylene": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"C",x:2.9,y:0,z:0},{e:"C",x:-1.45,y:2.51,z:0}, {e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"H",x:3.3,y:1.0,z:0},{e:"H",x:3.3,y:-0.5,z:0.87},{e:"H",x:3.3,y:-0.5,z:-0.87}, {e:"H",x:-0.78,y:3.35,z:0},{e:"H",x:-2.08,y:2.6,z:0.87},{e:"H",x:-2.08,y:2.6,z:-0.87}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[2,7,1],[1,8,1],[3,9,1],[4,10,1],[5,11,1],[6,12,1],[6,13,1],[6,14,1],[7,15,1],[7,16,1],[7,17,1]] }, "p_xylene": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"C",x:2.9,y:0,z:0},{e:"C",x:-2.9,y:0,z:0}, {e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"H",x:3.3,y:1.0,z:0},{e:"H",x:3.3,y:-0.5,z:0.87},{e:"H",x:3.3,y:-0.5,z:-0.87}, {e:"H",x:-3.3,y:-1.0,z:0},{e:"H",x:-3.3,y:0.5,z:0.87},{e:"H",x:-3.3,y:0.5,z:-0.87}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[3,7,1],[1,8,1],[2,9,1],[4,10,1],[5,11,1],[6,12,1],[6,13,1],[6,14,1],[7,15,1],[7,16,1],[7,17,1]] }, "styrene": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0}, {e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"C",x:2.8,y:0,z:0},{e:"H",x:3.3,y:-0.9,z:0},{e:"C",x:3.6,y:1.1,z:0}, {e:"H",x:3.2,y:2.1,z:0},{e:"H",x:4.7,y:1.0,z:0}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[1,6,1],[2,7,1],[3,8,1],[4,9,1],[5,10,1],[0,11,1],[11,12,1],[11,13,2],[13,14,1],[13,15,1]] }, "naphthalene": { atoms:[ {e:"C",x:0,y:0.7,z:0},{e:"C",x:0,y:-0.7,z:0}, {e:"C",x:1.21,y:1.4,z:0},{e:"C",x:2.42,y:0.7,z:0}, {e:"C",x:2.42,y:-0.7,z:0},{e:"C",x:1.21,y:-1.4,z:0}, {e:"C",x:-1.21,y:1.4,z:0},{e:"C",x:-2.42,y:0.7,z:0}, {e:"C",x:-2.42,y:-0.7,z:0},{e:"C",x:-1.21,y:-1.4,z:0}, {e:"H",x:1.21,y:2.48,z:0},{e:"H",x:3.36,y:1.24,z:0}, {e:"H",x:3.36,y:-1.24,z:0},{e:"H",x:1.21,y:-2.48,z:0}, {e:"H",x:-1.21,y:2.48,z:0},{e:"H",x:-3.36,y:1.24,z:0}, {e:"H",x:-3.36,y:-1.24,z:0},{e:"H",x:-1.21,y:-2.48,z:0} ], bonds:[ [0,1,1],[0,2,1],[2,3,1],[3,4,1],[4,5,1],[5,1,1], [1,9,1],[9,8,1],[8,7,1],[7,6,1],[6,0,1], [2,10,1],[3,11,1],[4,12,1],[5,13,1],[6,14,1],[7,15,1],[8,16,1],[9,17,1] ] }, // --- HALOGEN DERIVATIVES --- "CH3Cl": { atoms:[{e:"C",x:0,y:0,z:0},{e:"Cl",x:0,y:1.5,z:0},{e:"H",x:0.96,y:-0.5,z:0},{e:"H",x:-0.48,y:-0.5,z:0.84},{e:"H",x:-0.48,y:-0.5,z:-0.84}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1]] }, "CH2Cl2": { atoms:[{e:"C",x:0,y:0,z:0},{e:"H",x:0.63,y:0.63,z:0.63},{e:"H",x:-0.63,y:-0.63,z:0.63},{e:"Cl",x:1.01,y:-1.01,z:-1.01},{e:"Cl",x:-1.01,y:1.01,z:-1.01}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1]] }, "CHCl3": { atoms:[{e:"C",x:0,y:0,z:0},{e:"H",x:0,y:1.09,z:0},{e:"Cl",x:0,y:-0.58,z:1.65},{e:"Cl",x:1.43,y:-0.58,z:-0.825},{e:"Cl",x:-1.43,y:-0.58,z:-0.825}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1]] }, "CCl4": { atoms:[{e:"C",x:0,y:0,z:0},{e:"Cl",x:1.01,y:1.01,z:1.01},{e:"Cl",x:-1.01,y:-1.01,z:1.01},{e:"Cl",x:1.01,y:-1.01,z:-1.01},{e:"Cl",x:-1.01,y:1.01,z:-1.01}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1]] }, "CCl2F2": { atoms:[{e:"C",x:0,y:0,z:0},{e:"Cl",x:1.01,y:1.01,z:1.01},{e:"Cl",x:-1.01,y:-1.01,z:1.01},{e:"F",x:0.78,y:-0.78,z:-0.78},{e:"F",x:-0.78,y:0.78,z:-0.78}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1]] }, "C2H5Cl": { atoms:[{e:"C",x:-0.8,y:0,z:0},{e:"C",x:0.7,y:0,z:0},{e:"H",x:-1.15,y:1.03,z:0},{e:"H",x:-1.15,y:-0.51,z:0.89},{e:"H",x:-1.15,y:-0.51,z:-0.89},{e:"Cl",x:1.4,y:-1.2,z:0},{e:"H",x:1.1,y:0.5,z:0.89},{e:"H",x:1.1,y:0.5,z:-0.89}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[1,7,1]] }, "vinyl_chloride": { atoms:[{e:"C",x:-0.67,y:0,z:0},{e:"C",x:0.67,y:0,z:0},{e:"H",x:-1.25,y:0.92,z:0},{e:"H",x:-1.25,y:-0.92,z:0},{e:"H",x:1.25,y:0.92,z:0},{e:"Cl",x:1.61,y:-1.49,z:0}], bonds:[[0,1,2],[0,2,1],[0,3,1],[1,4,1],[1,5,1]] }, "1_chloropropane": { atoms:[{e:"C",x:0,y:0.4,z:0},{e:"C",x:-1.4,y:-0.4,z:0},{e:"C",x:1.4,y:-0.4,z:0}, {e:"H",x:0,y:0.9,z:0.88},{e:"H",x:0,y:0.9,z:-0.88},{e:"H",x:-1.4,y:-1.5,z:0}, {e:"H",x:-1.9,y:-0.05,z:0.88},{e:"H",x:-1.9,y:-0.05,z:-0.88}, {e:"H",x:1.4,y:-1.5,z:0},{e:"H",x:1.9,y:-0.05,z:0.88},{e:"Cl",x:2.2,y:0.2,z:-1.4}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[1,7,1],[2,8,1],[2,9,1],[2,10,1]] }, "2_chloropropane": { atoms:[{e:"C",x:0,y:0.4,z:0},{e:"C",x:-1.4,y:-0.4,z:0},{e:"C",x:1.4,y:-0.4,z:0}, {e:"Cl",x:0,y:1.26,z:1.52},{e:"H",x:0,y:0.9,z:-0.88}, {e:"H",x:-1.4,y:-1.5,z:0},{e:"H",x:-1.9,y:-0.05,z:0.88},{e:"H",x:-1.9,y:-0.05,z:-0.88}, {e:"H",x:1.4,y:-1.5,z:0},{e:"H",x:1.9,y:-0.05,z:0.88},{e:"H",x:1.9,y:-0.05,z:-0.88}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[1,7,1],[2,8,1],[2,9,1],[2,10,1]] }, // --- ALCOHOLS & PHENOLS --- "CH3OH": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:1.42,y:0,z:0},{e:"H",x:-0.37,y:1.03,z:0},{e:"H",x:-0.37,y:-0.51,z:0.89},{e:"H",x:-0.37,y:-0.51,z:-0.89},{e:"H",x:1.7,y:0.8,z:0}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[1,5,1]] }, "C2H5OH": { atoms:[{e:"C",x:-1.2,y:0.5,z:0},{e:"C",x:0,y:-0.3,z:0},{e:"O",x:1.2,y:0.5,z:0}, {e:"H",x:-1.2,y:1.55,z:0},{e:"H",x:-1.7,y:0.15,z:0.89},{e:"H",x:-1.7,y:0.15,z:-0.89}, {e:"H",x:0,y:-0.95,z:0.89},{e:"H",x:0,y:-0.95,z:-0.89},{e:"H",x:1.9,y:0.0,z:0}], bonds:[[0,1,1],[1,2,1],[0,3,1],[0,4,1],[0,5,1],[1,6,1],[1,7,1],[2,8,1]] }, "propan_2_ol": { atoms:[{e:"C",x:0,y:0.2,z:0},{e:"C",x:-1.3,y:-0.5,z:0},{e:"C",x:1.3,y:-0.5,z:0}, {e:"O",x:0,y:1.0,z:1.0},{e:"H",x:0,y:1.8,z:0.7},{e:"H",x:0,y:0.8,z:-0.9}, {e:"H",x:-1.3,y:-1.6,z:0},{e:"H",x:-1.9,y:-0.1,z:0.88},{e:"H",x:-1.9,y:-0.1,z:-0.88}, {e:"H",x:1.3,y:-1.6,z:0},{e:"H",x:1.9,y:-0.1,z:0.88},{e:"H",x:1.9,y:-0.1,z:-0.88}], bonds:[[0,1,1],[0,2,1],[0,3,1],[3,4,1],[0,5,1],[1,6,1],[1,7,1],[1,8,1],[2,9,1],[2,10,1],[2,11,1]] }, "ethane_1_2_diol": { atoms:[{e:"C",x:-0.76,y:0,z:0},{e:"C",x:0.76,y:0,z:0},{e:"O",x:-1.22,y:1.36,z:0},{e:"H",x:-2.22,y:1.36,z:0}, {e:"H",x:-1.1,y:-0.5,z:0.87},{e:"H",x:-1.1,y:-0.5,z:-0.87},{e:"O",x:1.22,y:-1.36,z:0}, {e:"H",x:2.22,y:-1.36,z:0},{e:"H",x:1.1,y:0.5,z:0.87},{e:"H",x:1.1,y:0.5,z:-0.87}], bonds:[[0,1,1],[0,2,1],[2,3,1],[0,4,1],[0,5,1],[1,6,1],[6,7,1],[1,8,1],[1,9,1]] }, "C3H5(OH)3": { atoms:[{e:"C",x:-1.5,y:0,z:0},{e:"C",x:0,y:0.8,z:0},{e:"C",x:1.5,y:0,z:0}, {e:"H",x:-1.5,y:-0.6,z:0.9},{e:"H",x:-1.5,y:-0.6,z:-0.9},{e:"H",x:0,y:1.4,z:0.9}, {e:"H",x:1.5,y:-0.6,z:0.9},{e:"H",x:1.5,y:-0.6,z:-0.9}, {e:"O",x:-2.6,y:0.8,z:0},{e:"H",x:-3.3,y:0.3,z:0}, {e:"O",x:0,y:1.6,z:-1.2},{e:"H",x:0.8,y:2.0,z:-1.2}, {e:"O",x:2.6,y:0.8,z:0},{e:"H",x:3.3,y:0.3,z:0}], bonds:[[0,1,1],[1,2,1],[0,3,1],[0,4,1],[0,8,1],[8,9,1],[1,5,1],[1,10,1],[10,11,1],[2,6,1],[2,7,1],[2,12,1],[12,13,1]] }, "C6H5OH": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"O",x:2.7,y:0,z:0},{e:"H",x:3.05,y:0.88,z:0},{e:"H",x:1.24,y:2.15,z:0}, {e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[6,7,1],[1,8,1],[2,9,1],[3,10,1],[4,11,1],[5,12,1]] }, // --- ALDEHYDES & KETONES --- "HCHO": { atoms:[{e:"C",x:0,y:0.2,z:0},{e:"O",x:0,y:-1.0,z:0},{e:"H",x:0.96,y:0.75,z:0},{e:"H",x:-0.96,y:0.75,z:0}], bonds:[[0,1,2],[0,2,1],[0,3,1]] }, "CH3CHO": { atoms:[{e:"C",x:-0.6,y:-0.2,z:0},{e:"C",x:0.8,y:0.3,z:0},{e:"O",x:-1.6,y:0.3,z:0}, {e:"H",x:-0.6,y:-1.3,z:0},{e:"H",x:0.9,y:1.4,z:0},{e:"H",x:1.3,y:-0.05,z:0.88},{e:"H",x:1.3,y:-0.05,z:-0.88}], bonds:[[0,1,1],[0,2,2],[0,3,1],[1,4,1],[1,5,1],[1,6,1]] }, "CH3COCH3": { atoms:[{e:"C",x:0,y:0.4,z:0},{e:"O",x:0,y:1.6,z:0},{e:"C",x:-1.4,y:-0.4,z:0},{e:"C",x:1.4,y:-0.4,z:0}, {e:"H",x:-1.4,y:-1.5,z:0},{e:"H",x:-1.9,y:-0.05,z:0.88},{e:"H",x:-1.9,y:-0.05,z:-0.88}, {e:"H",x:1.4,y:-1.5,z:0},{e:"H",x:1.9,y:-0.05,z:0.88},{e:"H",x:1.9,y:-0.05,z:-0.88}], bonds:[[0,1,2],[0,2,1],[0,3,1],[2,4,1],[2,5,1],[2,6,1],[3,7,1],[3,8,1],[3,9,1]] }, "butanone": { atoms:[{e:"C",x:-1.5,y:0.5,z:0},{e:"C",x:0,y:-0.3,z:0},{e:"C",x:1.5,y:0.5,z:0},{e:"C",x:2.8,y:-0.3,z:0}, {e:"O",x:0,y:-1.5,z:0},{e:"H",x:-1.5,y:1.6,z:0},{e:"H",x:-2.0,y:0.1,z:0.9},{e:"H",x:-2.0,y:0.1,z:-0.9}, {e:"H",x:1.5,y:1.1,z:0.9},{e:"H",x:1.5,y:1.1,z:-0.9},{e:"H",x:2.8,y:-1.4,z:0}, {e:"H",x:3.3,y:0.1,z:0.9},{e:"H",x:3.3,y:0.1,z:-0.9}], bonds:[[0,1,1],[1,2,1],[2,3,1],[1,4,2],[0,5,1],[0,6,1],[0,7,1],[2,8,1],[2,9,1],[3,10,1],[3,11,1],[3,12,1]] }, // --- CARBOXYLIC ACIDS --- "HCOOH": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:0,y:1.2,z:0},{e:"O",x:1.2,y:-0.5,z:0},{e:"H",x:2.0,y:-0.1,z:0},{e:"H",x:-1.0,y:-0.5,z:0}], bonds:[[0,1,2],[0,2,1],[2,3,1],[0,4,1]] }, "CH3COOH": { atoms:[{e:"C",x:0.6,y:0,z:0},{e:"C",x:-0.8,y:0,z:0},{e:"O",x:1.2,y:1.1,z:0},{e:"O",x:1.3,y:-1.1,z:0}, {e:"H",x:2.2,y:-0.9,z:0},{e:"H",x:-1.2,y:1.0,z:0},{e:"H",x:-1.2,y:-0.5,z:0.87},{e:"H",x:-1.2,y:-0.5,z:-0.87}], bonds:[[0,1,1],[0,2,2],[0,3,1],[3,4,1],[1,5,1],[1,6,1],[1,7,1]] }, "CH2=CHCOOH": { atoms:[{e:"C",x:-1.8,y:-0.5,z:0},{e:"C",x:-0.6,y:0.2,z:0},{e:"C",x:0.7,y:-0.2,z:0}, {e:"O",x:1.1,y:-1.3,z:0},{e:"O",x:1.6,y:0.8,z:0},{e:"H",x:-1.9,y:-1.5,z:0}, {e:"H",x:-2.7,y:0.1,z:0},{e:"H",x:-0.5,y:1.2,z:0},{e:"H",x:2.5,y:0.5,z:0}], bonds:[[0,1,2],[1,2,1],[2,3,2],[2,4,1],[0,5,1],[0,6,1],[1,7,1],[4,8,1]] }, "lactic_acid": { atoms:[{e:"C",x:0,y:0,z:0},{e:"H",x:0,y:1.1,z:0},{e:"C",x:-1.4,y:-0.5,z:0.5}, {e:"O",x:0.8,y:-0.5,z:1.0},{e:"C",x:0.5,y:-0.3,z:-1.4},{e:"H",x:0.5,y:0,z:1.8}, {e:"H",x:-2.1,y:0.1,z:0.1},{e:"H",x:-1.4,y:-1.5,z:0.1},{e:"H",x:-1.6,y:-0.4,z:1.6}, {e:"O",x:1.5,y:0.3,z:-1.8},{e:"O",x:-0.2,y:-1.1,z:-2.1},{e:"H",x:0.2,y:-1.3,z:-2.9}], bonds:[[0,1,1],[0,2,1],[0,3,1],[0,4,1],[3,5,1],[2,6,1],[2,7,1],[2,8,1],[4,9,2],[4,10,1],[10,11,1]] }, "oxalic_acid": { atoms:[{e:"C",x:-0.7,y:0,z:0},{e:"C",x:0.7,y:0,z:0},{e:"O",x:-1.3,y:1.1,z:0},{e:"O",x:-1.4,y:-1.1,z:0},{e:"H",x:-2.3,y:-0.9,z:0},{e:"O",x:1.3,y:-1.1,z:0},{e:"O",x:1.4,y:1.1,z:0},{e:"H",x:2.3,y:0.9,z:0}], bonds:[[0,1,1],[0,2,2],[0,3,1],[3,4,1],[1,5,2],[1,6,1],[6,7,1]] }, "malonic_acid": { atoms:[{e:"C",x:0,y:0.5,z:0},{e:"H",x:0,y:1.0,z:0.89},{e:"H",x:0,y:1.0,z:-0.89}, {e:"C",x:-1.3,y:-0.4,z:0},{e:"O",x:-1.3,y:-1.6,z:0},{e:"O",x:-2.5,y:0.2,z:0},{e:"H",x:-3.2,y:-0.4,z:0}, {e:"C",x:1.3,y:-0.4,z:0},{e:"O",x:1.3,y:-1.6,z:0},{e:"O",x:2.5,y:0.2,z:0},{e:"H",x:3.2,y:-0.4,z:0}], bonds:[[0,3,1],[0,7,1],[0,1,1],[0,2,1],[3,4,2],[3,5,1],[5,6,1],[7,8,2],[7,9,1],[9,10,1]] }, "succinic_acid": { atoms:[{e:"C",x:-0.7,y:0.5,z:0},{e:"C",x:0.7,y:-0.5,z:0},{e:"H",x:-0.7,y:1.0,z:0.89},{e:"H",x:-0.7,y:1.0,z:-0.89},{e:"H",x:0.7,y:-1.0,z:0.89},{e:"H",x:0.7,y:-1.0,z:-0.89},{e:"C",x:-2.0,y:-0.4,z:0},{e:"O",x:-2.0,y:-1.6,z:0},{e:"O",x:-3.2,y:0.2,z:0},{e:"H",x:-3.9,y:-0.4,z:0},{e:"C",x:2.0,y:0.4,z:0},{e:"O",x:2.0,y:1.6,z:0},{e:"O",x:3.2,y:-0.2,z:0},{e:"H",x:3.9,y:0.4,z:0}], bonds:[[0,1,1],[0,6,1],[1,10,1],[0,2,1],[0,3,1],[1,4,1],[1,5,1],[6,7,2],[6,8,1],[8,9,1],[10,11,2],[10,12,1],[12,13,1]] }, "citric_acid": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:0,y:1.4,z:0},{e:"H",x:0.8,y:1.6,z:0},{e:"C",x:-1.2,y:-0.8,z:-0.8},{e:"O",x:-1.4,y:-0.6,z:-1.9},{e:"O",x:-2.0,y:-1.5,z:-0.2},{e:"H",x:-2.7,y:-1.9,z:-0.6},{e:"C",x:1.2,y:-0.8,z:-0.8},{e:"H",x:1.0,y:-1.8,z:-0.8},{e:"H",x:1.5,y:-0.5,z:-1.8},{e:"C",x:2.5,y:-0.5,z:0.1},{e:"O",x:3.0,y:0.6,z:0.1},{e:"O",x:3.0,y:-1.5,z:0.8},{e:"H",x:3.8,y:-1.3,z:1.2},{e:"C",x:0,y:-0.5,z:1.4},{e:"H",x:-0.9,y:-0.3,z:1.9},{e:"H",x:0.9,y:-0.3,z:1.9},{e:"C",x:0,y:-2.0,z:1.6},{e:"O",x:-1.0,y:-2.6,z:1.8},{e:"O",x:1.1,y:-2.6,z:1.8},{e:"H",x:1.0,y:-3.5,z:1.9}], bonds:[[0,1,1],[1,2,1],[0,3,1],[3,4,2],[3,5,1],[5,6,1],[0,7,1],[7,8,1],[7,9,1],[7,10,1],[10,11,2],[10,12,1],[12,13,1],[0,14,1],[14,15,1],[14,16,1],[14,17,1],[17,18,2],[17,19,1],[19,20,1]] }, "benzoic_acid": { atoms:[{e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"H",x:1.24,y:2.15,z:0},{e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0}, {e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"C",x:2.9,y:0,z:0},{e:"O",x:3.6,y:1.1,z:0},{e:"O",x:3.5,y:-1.1,z:0},{e:"H",x:4.4,y:-1.0,z:0}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[1,6,1],[2,7,1],[3,8,1],[4,9,1],[5,10,1],[0,11,1],[11,12,2],[11,13,1],[13,14,1]] }, "aspirin": { atoms:[ {e:"C",x:1.4,y:0,z:0},{e:"C",x:0.7,y:1.21,z:0},{e:"C",x:-0.7,y:1.21,z:0}, {e:"C",x:-1.4,y:0,z:0},{e:"C",x:-0.7,y:-1.21,z:0},{e:"C",x:0.7,y:-1.21,z:0}, {e:"H",x:-1.24,y:2.15,z:0},{e:"H",x:-2.48,y:0,z:0},{e:"H",x:-1.24,y:-2.15,z:0},{e:"H",x:1.24,y:-2.15,z:0}, {e:"C",x:1.4,y:2.4,z:0},{e:"O",x:0.8,y:3.4,z:0},{e:"O",x:2.7,y:2.4,z:0},{e:"H",x:3.1,y:3.2,z:0}, {e:"O",x:2.7,y:0,z:0},{e:"C",x:3.4,y:-1.0,z:0},{e:"O",x:2.9,y:-2.0,z:0},{e:"C",x:4.9,y:-1.0,z:0}, {e:"H",x:5.3,y:-2.0,z:0},{e:"H",x:5.3,y:-0.4,z:0.88},{e:"H",x:5.3,y:-0.4,z:-0.88} ], bonds:[ [0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1], [2,6,1],[3,7,1],[4,8,1],[5,9,1], [1,10,1],[10,11,2],[10,12,1],[12,13,1], [0,14,1],[14,15,1],[15,16,2],[15,17,1],[17,18,1],[17,19,1],[17,20,1] ] }, // --- ESTERS --- "HCOOCH3": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:0,y:1.2,z:0},{e:"O",x:1.1,y:-0.5,z:0},{e:"H",x:-0.9,y:-0.5,z:0},{e:"C",x:2.3,y:0.2,z:0},{e:"H",x:3.1,y:-0.4,z:0},{e:"H",x:2.3,y:0.8,z:0.9},{e:"H",x:2.3,y:0.8,z:-0.9}], bonds:[[0,1,2],[0,2,1],[0,3,1],[2,4,1],[4,5,1],[4,6,1],[4,7,1]] }, "CH3COOCH3": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:0,y:1.2,z:0},{e:"O",x:1.1,y:-0.5,z:0},{e:"C",x:-1.3,y:-0.6,z:0},{e:"C",x:2.3,y:0.2,z:0},{e:"H",x:-1.3,y:-1.7,z:0},{e:"H",x:-1.8,y:-0.2,z:0.9},{e:"H",x:-1.8,y:-0.2,z:-0.9},{e:"H",x:3.1,y:-0.4,z:0},{e:"H",x:2.3,y:0.8,z:0.9},{e:"H",x:2.3,y:0.8,z:-0.9}], bonds:[[0,1,2],[0,2,1],[0,3,1],[3,5,1],[3,6,1],[3,7,1],[2,4,1],[4,8,1],[4,9,1],[4,10,1]] }, "CH3COOC2H5": { atoms:[{e:"C",x:0,y:0,z:0},{e:"O",x:0,y:1.2,z:0},{e:"O",x:1.1,y:-0.5,z:0},{e:"C",x:-1.3,y:-0.6,z:0},{e:"C",x:2.4,y:0.1,z:0},{e:"C",x:3.6,y:-0.8,z:0},{e:"H",x:-1.3,y:-1.7,z:0},{e:"H",x:-1.8,y:-0.2,z:0.9},{e:"H",x:-1.8,y:-0.2,z:-0.9},{e:"H",x:2.4,y:0.7,z:0.9},{e:"H",x:2.4,y:0.7,z:-0.9},{e:"H",x:3.6,y:-1.4,z:0.9},{e:"H",x:3.6,y:-1.4,z:-0.9},{e:"H",x:4.5,y:-0.2,z:0}], bonds:[[0,1,2],[0,2,1],[0,3,1],[3,6,1],[3,7,1],[3,8,1],[2,4,1],[4,5,1],[4,9,1],[4,10,1],[5,11,1],[5,12,1],[5,13,1]] }, "isoamyl_acetate": { atoms:[{e:"C",x:-3.2,y:0.3,z:0},{e:"O",x:-3.2,y:1.5,z:0},{e:"O",x:-2.1,y:-0.4,z:0},{e:"C",x:-4.5,y:-0.5,z:0},{e:"H",x:-4.5,y:-1.6,z:0},{e:"H",x:-5.0,y:-0.1,z:0.9},{e:"H",x:-5.0,y:-0.1,z:-0.9},{e:"C",x:-0.8,y:-0.1,z:0},{e:"H",x:-0.8,y:1.0,z:0},{e:"H",x:-0.5,y:-0.4,z:0.9},{e:"C",x:0.5,y:-0.8,z:-0.5},{e:"H",x:0.2,y:-1.8,z:-0.5},{e:"H",x:0.5,y:-0.4,z:-1.5},{e:"C",x:1.8,y:-0.1,z:0},{e:"H",x:1.8,y:-0.1,z:1.1},{e:"C",x:1.8,y:1.4,z:0},{e:"H",x:1.3,y:1.8,z:-0.9},{e:"H",x:2.8,y:1.8,z:0},{e:"H",x:1.3,y:1.8,z:0.9},{e:"C",x:3.1,y:-0.7,z:-0.5},{e:"H",x:3.1,y:-1.8,z:-0.5},{e:"H",x:3.6,y:-0.3,z:0.4},{e:"H",x:3.6,y:-0.3,z:-1.4}], bonds:[[0,1,2],[0,2,1],[0,3,1],[3,4,1],[3,5,1],[3,6,1],[2,7,1],[7,10,1],[7,8,1],[7,9,1],[10,13,1],[10,11,1],[10,12,1],[13,15,1],[13,19,1],[13,14,1],[15,16,1],[15,17,1],[15,18,1],[19,20,1],[19,21,1],[19,22,1]] }, // --- AMINES & HETEROCYCLICS --- "CH3NH2": { atoms:[ {e:"N",x:0.000,y:0.000,z:0.000}, {e:"C",x:-1.470,y:0.000,z:0.000}, {e:"H",x:0.380,y:0.930,z:0.380}, {e:"H",x:0.380,y:-0.930,z:0.380}, {e:"H",x:-1.850,y:1.030,z:0.000}, {e:"H",x:-1.850,y:-0.515,z:0.890}, {e:"H",x:-1.850,y:-0.515,z:-0.890} ], bonds:[[0,1,1],[0,2,1],[0,3,1],[1,4,1],[1,5,1],[1,6,1]] }, "C2H5NH2": { atoms:[ {e:"N",x:1.340,y:0.000,z:0.000}, {e:"C",x:0.000,y:0.730,z:0.000}, {e:"C",x:-1.220,y:-0.170,z:0.000}, {e:"H",x:1.640,y:0.450,z:0.870}, {e:"H",x:1.640,y:0.450,z:-0.870}, {e:"H",x:0.050,y:1.370,z:0.880}, {e:"H",x:0.050,y:1.370,z:-0.880}, {e:"H",x:-1.200,y:-0.810,z:0.880}, {e:"H",x:-1.200,y:-0.810,z:-0.880}, {e:"H",x:-2.130,y:0.440,z:0.000} ], bonds:[[0,1,1],[1,2,1],[0,3,1],[0,4,1],[1,5,1],[1,6,1],[2,7,1],[2,8,1],[2,9,1]] }, "CH3NHCH3": { atoms:[ {e:"N",x:0.000,y:0.000,z:0.000}, {e:"H",x:0.000,y:1.010,z:-0.360}, {e:"C",x:1.230,y:-0.500,z:0.600}, {e:"C",x:-1.230,y:-0.500,z:0.600}, {e:"H",x:1.230,y:-1.590,z:0.580}, {e:"H",x:2.090,y:-0.130,z:0.060}, {e:"H",x:1.280,y:-0.180,z:1.640}, {e:"H",x:-1.230,y:-1.590,z:0.580}, {e:"H",x:-2.090,y:-0.130,z:0.060}, {e:"H",x:-1.280,y:-0.180,z:1.640} ], bonds:[[0,1,1],[0,2,1],[0,3,1],[2,4,1],[2,5,1],[2,6,1],[3,7,1],[3,8,1],[3,9,1]] }, "(CH3)3N": { atoms:[ {e:"N",x:0.000,y:0.400,z:0.000}, {e:"C",x:0.000,y:-0.200,z:1.380}, {e:"C",x:1.196,y:-0.200,z:-0.690}, {e:"C",x:-1.196,y:-0.200,z:-0.690}, {e:"H",x:0.000,y:-1.290,z:1.380}, {e:"H",x:0.890,y:0.130,z:1.920}, {e:"H",x:-0.890,y:0.130,z:1.920}, {e:"H",x:1.240,y:-1.290,z:-0.700}, {e:"H",x:2.090,y:0.130,z:-0.230}, {e:"H",x:1.230,y:0.130,z:-1.720}, {e:"H",x:-1.240,y:-1.290,z:-0.700}, {e:"H",x:-2.090,y:0.130,z:-0.230}, {e:"H",x:-1.230,y:0.130,z:-1.720} ], bonds:[[0,1,1],[0,2,1],[0,3,1],[1,4,1],[1,5,1],[1,6,1],[2,7,1],[2,8,1],[2,9,1],[3,10,1],[3,11,1],[3,12,1]] }, "C6H5NH2": { atoms:[ {e:"C",x:1.400,y:0.000,z:0.000}, {e:"C",x:0.700,y:1.210,z:0.000}, {e:"C",x:-0.700,y:1.210,z:0.000}, {e:"C",x:-1.400,y:0.000,z:0.000}, {e:"C",x:-0.700,y:-1.210,z:0.000}, {e:"C",x:0.700,y:-1.210,z:0.000}, {e:"N",x:2.840,y:0.000,z:0.200}, {e:"H",x:3.280,y:0.820,z:-0.200}, {e:"H",x:3.280,y:-0.820,z:-0.200}, {e:"H",x:1.240,y:2.150,z:0.000}, {e:"H",x:-1.240,y:2.150,z:0.000}, {e:"H",x:-2.480,y:0.000,z:0.000}, {e:"H",x:-1.240,y:-2.150,z:0.000}, {e:"H",x:1.240,y:-2.150,z:0.000} ], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[0,6,1],[6,7,1],[6,8,1],[1,9,1],[2,10,1],[3,11,1],[4,12,1],[5,13,1]] }, "pyridine": { atoms:[ {e:"N",x:0,y:-1.4,z:0},{e:"C",x:1.21,y:-0.7,z:0},{e:"C",x:1.21,y:0.7,z:0}, {e:"C",x:0,y:1.4,z:0},{e:"C",x:-1.21,y:0.7,z:0},{e:"C",x:-1.21,y:-0.7,z:0}, {e:"H",x:2.15,y:-1.24,z:0},{e:"H",x:2.15,y:1.24,z:0},{e:"H",x:0,y:2.48,z:0}, {e:"H",x:-2.15,y:1.24,z:0},{e:"H",x:-2.15,y:-1.24,z:0} ], bonds:[[0,1,2],[1,2,1],[2,3,2],[3,4,1],[4,5,2],[5,0,1],[1,6,1],[2,7,1],[3,8,1],[4,9,1],[5,10,1]] }, "urea": { atoms:[ {e:"C",x:0,y:0,z:0},{e:"O",x:0,y:1.2,z:0},{e:"N",x:-1.17,y:-0.67,z:0},{e:"N",x:1.17,y:-0.67,z:0}, {e:"H",x:-2.04,y:-0.18,z:0},{e:"H",x:-1.17,y:-1.67,z:0},{e:"H",x:2.04,y:-0.18,z:0},{e:"H",x:1.17,y:-1.67,z:0} ], bonds:[[0,1,2],[0,2,1],[0,3,1],[2,4,1],[2,5,1],[3,6,1],[3,7,1]] }, // --- CARBOHYDRATES --- "alpha_glucose": { atoms:[{e:"O",x:0.9,y:-0.5,z:-0.5},{e:"C",x:1.1,y:0.7,z:0.2},{e:"C",x:0,y:1.3,z:-0.6},{e:"C",x:-1.1,y:0.7,z:0.2},{e:"C",x:-1.1,y:-0.7,z:-0.4},{e:"C",x:0,y:-1.2,z:0.4},{e:"C",x:-0.1,y:-2.7,z:0.0},{e:"O",x:-0.2,y:-3.3,z:1.3},{e:"O",x:1.3,y:0.8,z:1.6},{e:"O",x:0,y:2.7,z:-0.4},{e:"O",x:-2.3,y:1.3,z:-0.2},{e:"O",x:-2.3,y:-1.1,z:0.2},{e:"H",x:2.0,y:1.0,z:-0.3},{e:"H",x:0,y:1.1,z:-1.7},{e:"H",x:-1.1,y:0.7,z:1.3},{e:"H",x:-1.1,y:-0.7,z:-1.5},{e:"H",x:0,y:-1.0,z:1.5},{e:"H",x:0.8,y:-3.0,z:-0.5},{e:"H",x:-1.0,y:-3.0,z:-0.5},{e:"H",x:2.1,y:0.4,z:1.8},{e:"H",x:0.8,y:3.1,z:-0.1},{e:"H",x:-3.0,y:0.9,z:0.3},{e:"H",x:-2.5,y:-0.4,z:0.8},{e:"H",x:-1.0,y:-3.1,z:1.8}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[5,6,1],[6,7,1],[1,8,1],[2,9,1],[3,10,1],[4,11,1],[1,12,1],[2,13,1],[3,14,1],[4,15,1],[5,16,1],[6,17,1],[6,18,1],[8,19,1],[9,20,1],[10,21,1],[11,22,1],[7,23,1]] }, "beta_glucose": { atoms:[{e:"O",x:0.9,y:-0.5,z:-0.5},{e:"C",x:1.1,y:0.7,z:0.2},{e:"C",x:0,y:1.3,z:-0.6},{e:"C",x:-1.1,y:0.7,z:0.2},{e:"C",x:-1.1,y:-0.7,z:-0.4},{e:"C",x:0,y:-1.2,z:0.4},{e:"C",x:-0.1,y:-2.7,z:0.0},{e:"O",x:-0.2,y:-3.3,z:1.3},{e:"O",x:2.3,y:0.9,z:-0.4},{e:"O",x:0,y:2.7,z:-0.4},{e:"O",x:-2.3,y:1.3,z:-0.2},{e:"O",x:-2.3,y:-1.1,z:0.2},{e:"H",x:1.1,y:0.7,z:1.3},{e:"H",x:0,y:1.1,z:-1.7},{e:"H",x:-1.1,y:0.7,z:1.3},{e:"H",x:-1.1,y:-0.7,z:-1.5},{e:"H",x:0,y:-1.0,z:1.5},{e:"H",x:0.8,y:-3.0,z:-0.5},{e:"H",x:-1.0,y:-3.0,z:-0.5},{e:"H",x:3.0,y:0.3,z:0.0},{e:"H",x:0.8,y:3.1,z:-0.1},{e:"H",x:-3.0,y:0.9,z:0.3},{e:"H",x:-2.5,y:-0.4,z:0.8},{e:"H",x:-1.0,y:-3.1,z:1.8}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,5,1],[5,0,1],[5,6,1],[6,7,1],[1,8,1],[2,9,1],[3,10,1],[4,11,1],[1,12,1],[2,13,1],[3,14,1],[4,15,1],[5,16,1],[6,17,1],[6,18,1],[8,19,1],[9,20,1],[10,21,1],[11,22,1],[7,23,1]] }, "alpha_fructose": { atoms:[{e:"O",x:0,y:-1.0,z:-0.5},{e:"C",x:1.0,y:0,z:0},{e:"C",x:0.3,y:1.3,z:0.3},{e:"C",x:-0.8,y:1.1,z:-0.4},{e:"C",x:-1.1,y:-0.3,z:0.2},{e:"C",x:2.2,y:-0.5,z:0.6},{e:"O",x:3.2,y:0.4,z:0.8},{e:"C",x:-2.4,y:-0.8,z:-0.4},{e:"O",x:-3.4,y:-0.2,z:0.3},{e:"O",x:1.4,y:0.3,z:-1.4},{e:"O",x:0.6,y:2.5,z:-0.4},{e:"O",x:-1.5,y:1.8,z:0.5},{e:"H",x:0.2,y:1.3,z:1.4},{e:"H",x:-0.6,y:1.1,z:-1.5},{e:"H",x:-1.2,y:-0.3,z:1.3},{e:"H",x:1.9,y:-0.9,z:1.6},{e:"H",x:2.5,y:-1.3,z:0.0},{e:"H",x:-2.3,y:-1.9,z:-0.3},{e:"H",x:-2.7,y:-0.6,z:-1.4},{e:"H",x:3.8,y:0.1,z:0.1},{e:"H",x:2.3,y:0.6,z:-1.5},{e:"H",x:1.5,y:2.5,z:-0.7},{e:"H",x:-1.1,y:2.7,z:0.3},{e:"H",x:-3.1,y:-0.3,z:1.2}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,0,1],[1,5,1],[5,6,1],[4,7,1],[7,8,1],[1,9,1],[2,10,1],[3,11,1],[2,12,1],[3,13,1],[4,14,1],[5,15,1],[5,16,1],[7,17,1],[7,18,1],[6,19,1],[9,20,1],[10,21,1],[11,22,1],[8,23,1]] }, "beta_fructose": { atoms:[{e:"O",x:0,y:-1.0,z:-0.5},{e:"C",x:1.0,y:0,z:0},{e:"C",x:0.3,y:1.3,z:0.3},{e:"C",x:-0.8,y:1.1,z:-0.4},{e:"C",x:-1.1,y:-0.3,z:0.2},{e:"C",x:2.2,y:-0.5,z:-0.6},{e:"O",x:3.2,y:0.4,z:-0.8},{e:"C",x:-2.4,y:-0.8,z:-0.4},{e:"O",x:-3.4,y:-0.2,z:0.3},{e:"O",x:1.4,y:0.3,z:1.4},{e:"O",x:0.6,y:2.5,z:-0.4},{e:"O",x:-1.5,y:1.8,z:0.5},{e:"H",x:0.2,y:1.3,z:1.4},{e:"H",x:-0.6,y:1.1,z:-1.5},{e:"H",x:-1.2,y:-0.3,z:1.3},{e:"H",x:1.9,y:-0.9,z:-1.6},{e:"H",x:2.5,y:-1.3,z:0.0},{e:"H",x:-2.3,y:-1.9,z:-0.3},{e:"H",x:-2.7,y:-0.6,z:-1.4},{e:"H",x:3.8,y:0.1,z:-0.1},{e:"H",x:2.3,y:0.6,z:1.2},{e:"H",x:1.5,y:2.5,z:-0.7},{e:"H",x:-1.1,y:2.8,z:0.3},{e:"H",x:-3.1,y:-0.3,z:1.2}], bonds:[[0,1,1],[1,2,1],[2,3,1],[3,4,1],[4,0,1],[1,5,1],[5,6,1],[4,7,1],[7,8,1],[1,9,1],[2,10,1],[3,11,1],[2,12,1],[3,13,1],[4,14,1],[5,15,1],[5,16,1],[7,17,1],[7,18,1],[6,19,1],[9,20,1],[10,21,1],[11,22,1],[8,23,1]] }, // Khởi tạo phím rỗng cho các đường đôi, chúng sẽ được sinh ra ở initComplexMolecules() "saccharose": { atoms: [], bonds: [] }, "maltose": { atoms: [], bonds: [] }, // --- AMINO ACIDS --- "Gly": { atoms:[ {e:"N",x:1.201,y:0.847,z:0.000}, {e:"C",x:0.000,y:0.000,z:0.000}, {e:"C",x:-1.250,y:0.810,z:0.000}, {e:"O",x:-1.220,y:2.040,z:0.000}, {e:"O",x:-2.390,y:0.050,z:0.000}, {e:"H",x:-3.230,y:0.540,z:0.000}, {e:"H",x:0.080,y:-0.630,z:0.890}, {e:"H",x:0.080,y:-0.630,z:-0.890}, {e:"H",x:1.180,y:1.450,z:0.820}, {e:"H",x:1.180,y:1.450,z:-0.820} ], bonds:[[0,1,1],[1,2,1],[2,3,2],[2,4,1],[4,5,1],[1,6,1],[1,7,1],[0,8,1],[0,9,1]] }, "Ala": { atoms:[ {e:"N",x:1.201,y:0.847,z:0.000}, {e:"C",x:0.000,y:0.000,z:0.000}, {e:"C",x:-1.250,y:0.810,z:0.000}, {e:"O",x:-1.220,y:2.040,z:0.000}, {e:"O",x:-2.390,y:0.050,z:0.000}, {e:"H",x:-3.230,y:0.540,z:0.000}, {e:"H",x:0.100,y:-0.560,z:0.930}, {e:"C",x:0.140,y:-0.820,z:-1.270}, {e:"H",x:-0.800,y:-1.350,z:-1.450}, {e:"H",x:0.950,y:-1.550,z:-1.190}, {e:"H",x:0.380,y:-0.170,z:-2.120}, {e:"H",x:1.180,y:1.450,z:0.820}, {e:"H",x:1.180,y:1.450,z:-0.820} ], bonds:[[0,1,1],[1,2,1],[2,3,2],[2,4,1],[4,5,1],[1,6,1],[1,7,1],[7,8,1],[7,9,1],[7,10,1],[0,11,1],[0,12,1]] }, "Val": { atoms:[ {e:"N",x:1.201,y:0.847,z:0.000}, {e:"C",x:0.000,y:0.000,z:0.000}, {e:"C",x:-1.250,y:0.810,z:0.000}, {e:"O",x:-1.220,y:2.040,z:0.000}, {e:"O",x:-2.390,y:0.050,z:0.000}, {e:"H",x:-3.230,y:0.540,z:0.000}, {e:"H",x:0.100,y:-0.560,z:0.930}, {e:"C",x:0.130,y:-0.840,z:-1.270}, {e:"H",x:1.100,y:-1.350,z:-1.330}, {e:"C",x:-0.980,y:-1.880,z:-1.280}, {e:"H",x:-0.760,y:-2.640,z:-0.530}, {e:"H",x:-1.940,y:-1.380,z:-1.100}, {e:"H",x:-1.030,y:-2.380,z:-2.250}, {e:"C",x:0.190,y:-0.100,z:-2.590}, {e:"H",x:1.150,y:0.420,z:-2.640}, {e:"H",x:-0.620,y:0.630,z:-2.700}, {e:"H",x:0.110,y:-0.770,z:-3.440}, {e:"H",x:1.180,y:1.450,z:0.820}, {e:"H",x:1.180,y:1.450,z:-0.820} ], bonds:[[0,1,1],[1,2,1],[2,3,2],[2,4,1],[4,5,1],[1,6,1],[1,7,1],[7,8,1],[7,9,1],[7,13,1],[9,10,1],[9,11,1],[9,12,1],[13,14,1],[13,15,1],[13,16,1],[0,17,1],[0,18,1]] }, "Glu": { atoms:[ {e:"N",x:1.201,y:0.847,z:0.000}, {e:"C",x:0.000,y:0.000,z:0.000}, {e:"C",x:-1.250,y:0.810,z:0.000}, {e:"O",x:-1.220,y:2.040,z:0.000}, {e:"O",x:-2.390,y:0.050,z:0.000}, {e:"H",x:-3.230,y:0.540,z:0.000}, {e:"H",x:0.100,y:-0.560,z:0.930}, {e:"C",x:0.140,y:-0.820,z:-1.270}, {e:"H",x:1.100,y:-1.320,z:-1.350}, {e:"H",x:0.060,y:-0.190,z:-2.160}, {e:"C",x:-0.930,y:-1.930,z:-1.300}, {e:"H",x:-1.900,y:-1.440,z:-1.200}, {e:"H",x:-0.830,y:-2.570,z:-0.420}, {e:"C",x:-0.830,y:-2.740,z:-2.590}, {e:"O",x:0.200,y:-2.850,z:-3.270}, {e:"O",x:-1.920,y:-3.350,z:-2.850}, {e:"H",x:-1.830,y:-3.950,z:-3.590}, {e:"H",x:1.180,y:1.450,z:0.820}, {e:"H",x:1.180,y:1.450,z:-0.820} ], bonds:[[0,1,1],[1,2,1],[2,3,2],[2,4,1],[4,5,1],[1,6,1],[1,7,1],[7,8,1],[7,9,1],[7,10,1],[10,11,1],[10,12,1],[10,13,1],[13,14,2],[13,15,1],[15,16,1],[0,17,1],[0,18,1]] }, "Lys": { atoms:[ {e:"N",x:1.201,y:0.847,z:0.000}, {e:"C",x:0.000,y:0.000,z:0.000}, {e:"C",x:-1.250,y:0.810,z:0.000}, {e:"O",x:-1.220,y:2.040,z:0.000}, {e:"O",x:-2.390,y:0.050,z:0.000}, {e:"H",x:-3.230,y:0.540,z:0.000}, {e:"H",x:0.100,y:-0.560,z:0.930}, {e:"C",x:0.140,y:-0.820,z:-1.270}, {e:"H",x:1.100,y:-1.320,z:-1.350}, {e:"H",x:0.060,y:-0.190,z:-2.160}, {e:"C",x:-0.930,y:-1.930,z:-1.300}, {e:"H",x:-1.900,y:-1.430,z:-1.200}, {e:"H",x:-0.840,y:-2.570,z:-0.420}, {e:"C",x:-0.830,y:-2.760,z:-2.570}, {e:"H",x:0.140,y:-3.270,z:-2.620}, {e:"H",x:-1.070,y:-2.130,z:-3.430}, {e:"C",x:-1.900,y:-3.840,z:-2.600}, {e:"H",x:-2.880,y:-3.340,z:-2.530}, {e:"H",x:-1.790,y:-4.480,z:-1.720}, {e:"N",x:-1.820,y:-4.620,z:-3.840}, {e:"H",x:-0.880,y:-4.420,z:-4.240}, {e:"H",x:-2.540,y:-4.280,z:-4.490}, {e:"H",x:1.180,y:1.450,z:0.820}, {e:"H",x:1.180,y:1.450,z:-0.820} ], bonds:[[0,1,1],[1,2,1],[2,3,2],[2,4,1],[4,5,1],[1,6,1],[1,7,1],[7,8,1],[7,9,1],[7,10,1],[10,11,1],[10,12,1],[10,13,1],[13,14,1],[13,15,1],[13,16,1],[16,17,1],[16,18,1],[16,19,1],[19,20,1],[19,21,1],[0,22,1],[0,23,1]] } }; // ===================================================================== // P5.JS CORE & INIT (ĐÃ SỬA THUẬT TOÁN ĐỂ BẢO TOÀN sp3 100%) // ===================================================================== function preload() { myFont = loadFont('https://cdnjs.cloudflare.com/ajax/libs/topcoat/0.8.0/font/SourceCodePro-Bold.otf'); } // Tổng hợp Carbohydrates phức tạp bằng thuật toán dịch điểm hoàn hảo function initComplexMolecules() { if (!MOLECULE_DATA["alpha_glucose"] || !MOLECULE_DATA["beta_fructose"]) return; let glc = MOLECULE_DATA["alpha_glucose"]; let fru = MOLECULE_DATA["beta_fructose"]; const centerMolecule = (atoms) => { let cx = 0, cy = 0, cz = 0; for (let a of atoms) { cx += a.x; cy += a.y; cz += a.z; } cx /= atoms.length; cy /= atoms.length; cz /= atoms.length; for (let a of atoms) { a.x -= cx; a.y -= cy; a.z -= cz; } }; // --- MALTOSE --- (alpha-D-Glcp-(1->4)-D-Glcp) // Thuật toán giữ lại O1 của phân tử 1 làm cầu nối. // Dịch toàn bộ phân tử 2 sao cho điểm O4 cũ của nó trùng khít vào O1 của phân tử 1. // Điều này giúp liên kết C4 mới tạo ra cùng hướng với liên kết C4-O4 cũ => giữ nguyên vẹn sp3. let m_atoms = [], m_bonds = [], m_map1 = {}, m_map2 = {}; // Nạp Glucose 1 (bỏ H của O1) for(let i=0; i2)-beta-D-Fruf) // Tương tự, tịnh tiến vòng Fructose sao cho O2 của nó khớp hoàn hảo vào O1 của Glucose. // Trước khi tịnh tiến, lật trục Y cho Fructose xoay ra hướng ngoài để không đè vào vòng Glucose. let s_atoms = [], s_bonds = [], s_map1 = {}, s_map2 = {}; // Nạp Glucose (Bỏ H của O1) for(let i=0; i ({e: a.e, x: -a.x, y: a.y, z: -a.z})); // Tính khoảng dịch chuyển O2 -> O1 let o1_glc_suc = glc.atoms[8]; let o2_fru_rot = fru_rot[9]; let s_dx = o1_glc_suc.x - o2_fru_rot.x; let s_dy = o1_glc_suc.y - o2_fru_rot.y; let s_dz = o1_glc_suc.z - o2_fru_rot.z; // Nạp Fructose (Bỏ đi O2 và H-O2) for(let i=0; i false; pixelDensity(window.devicePixelRatio > 1 ? 1.5 : 1); textFont(myFont); textSize(16); textAlign(CENTER, CENTER); document.getElementById('molecule-select').addEventListener('change', function () { loadMolecule(this.value); this.classList.add('has-value'); if (window.innerWidth <= 768) toggleMenu(false); }); document.getElementById('toggle-rotate').addEventListener('click', function () { isRotating = !isRotating; updateButtonsText(); this.classList.toggle('active'); }); document.getElementById('toggle-labels').addEventListener('click', function () { showLabels = !showLabels; updateButtonsText(); this.classList.toggle('active'); }); document.getElementById('language-select').addEventListener('change', function () { setLanguage(this.value); }); document.getElementById('btn-save-image').addEventListener('click', captureImageDesktop); document.getElementById('mobile-menu-btn').addEventListener('click', () => toggleMenu(true)); document.getElementById('close-menu-btn').addEventListener('click', () => toggleMenu(false)); document.getElementById('menu-overlay').addEventListener('click', () => toggleMenu(false)); const popup = document.getElementById('save-popup-overlay'); document.getElementById('quick-snap-btn').addEventListener('click', () => { popup.classList.remove('hidden'); isRotating = false; document.getElementById('toggle-rotate').classList.remove('active'); }); document.getElementById('mobile-cancel-btn').addEventListener('click', () => { popup.classList.add('hidden'); isRotating = true; document.getElementById('toggle-rotate').classList.add('active'); }); document.getElementById('mobile-save-btn').addEventListener('click', () => { captureImageMobile(); popup.classList.add('hidden'); }); setTimeout(windowResized, 100); setLanguage('vi'); } function toggleMenu(show) { const ui = document.getElementById('ui-container'); const ov = document.getElementById('menu-overlay'); if (show) { ui.classList.add('open'); ov.classList.add('active'); } else { ui.classList.remove('open'); ov.classList.remove('active'); } } function touchStarted() { if (touches.length === 1) { isDragging = true; lastX = touches[0].x; lastY = touches[0].y; } else if (touches.length === 2) { isDragging = false; let dx = touches[1].x - touches[0].x, dy = touches[1].y - touches[0].y; initialDist = Math.sqrt(dx*dx + dy*dy); initialZoom = zoom; initialPanX = panX; initialPanY = panY; lastX = (touches[0].x + touches[1].x) / 2; lastY = (touches[0].y + touches[1].y) / 2; } } function touchMoved() { if (mouseX < 0 || mouseX > width || mouseY < 0 || mouseY > height) return true; if (touches.length === 1 && isDragging) { rotY += (touches[0].x - lastX) * 0.015; rotX += (touches[0].y - lastY) * 0.015; lastX = touches[0].x; lastY = touches[0].y; } else if (touches.length === 2) { let dx = touches[1].x - touches[0].x, dy = touches[1].y - touches[0].y; let d = Math.sqrt(dx*dx + dy*dy); if (initialDist > 0) zoom = constrain(initialZoom * (d / initialDist), 0.1, 5); let cx = (touches[0].x + touches[1].x) / 2; let cy = (touches[0].y + touches[1].y) / 2; panX = initialPanX + (cx - lastX); panY = initialPanY + (cy - lastY); } return false; } function mousePressed() { if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { isDragging = true; lastX = mouseX; lastY = mouseY; } } function mouseReleased() { isDragging = false; } function mouseDragged() { if (isDragging && touches.length === 0) { let dx = mouseX - lastX, dy = mouseY - lastY; if (mouseButton === LEFT) { rotY += dx * 0.01; rotX += dy * 0.01; } else if (mouseButton === RIGHT) { panX += dx; panY += dy; } lastX = mouseX; lastY = mouseY; } } function mouseWheel(event) { if (mouseX > 0 && mouseX < width && mouseY > 0 && mouseY < height) { zoom = constrain(zoom + event.delta * -0.001, 0.1, 5); return false; } return true; } // ===================================================================== // RENDER // ===================================================================== function renderScene(pg, w, h, sFactor = 1, isSnapshot = false) { pg.clear(); if (document.getElementById('snap-format').value === 'jpg' || sFactor === 1) pg.background(0); if (isSnapshot) { const fov = PI / 6, camZ = (h / 2.0) / Math.tan(fov / 2.0); pg.camera(0, 0, camZ, 0, 0, 0, 0, 1, 0); pg.perspective(fov, w / h, 10, 500000); } pg.noStroke(); pg.ambientLight(100); pg.directionalLight(180, 180, 180, 0.5, 1, -1); pg.pointLight(100, 100, 100, 0, 0, 500); pg.push(); pg.translate(panX * sFactor, panY * sFactor, 0); pg.scale(zoom * sFactor); pg.rotateX(rotX); pg.rotateY(rotY); pg.rotateY(autoRotationAngle); if (!currentMoleculeKey) { pg.push(); pg.rotateY(-(rotY + autoRotationAngle)); pg.rotateX(-rotX); pg.scale(1 / (zoom * sFactor)); if (sFactor === 1) { let gl = pg._renderer.GL; gl.disable(gl.DEPTH_TEST); pg.textSize(14); pg.fill(150); pg.text(TRANSLATIONS[currentLang].canvasMsg, 0, 0); gl.enable(gl.DEPTH_TEST); } pg.pop(); pg.pop(); return; } for (let b of bonds) { let a1 = atoms[b[0]], a2 = atoms[b[1]], order = b[2] || 1; drawBondMulti(pg, createVector(a1.x * SCALE, a1.y * SCALE, a1.z * SCALE), createVector(a2.x * SCALE, a2.y * SCALE, a2.z * SCALE), order); } if (SINGLE_RING_AROMATIC.includes(currentMoleculeKey)) { drawAromaticRing(pg, 0, 0); } else if (DOUBLE_RING_AROMATIC.includes(currentMoleculeKey)) { drawAromaticRing(pg, 1.21 * SCALE, 0); drawAromaticRing(pg, -1.21 * SCALE, 0); } for (let atom of atoms) { let x = atom.x * SCALE, y = atom.y * SCALE, z = atom.z * SCALE; let ei = ELEMENTS[atom.e] || { color:[200,200,200], radius:30, textColor:[0,0,0] }; pg.push(); pg.translate(x, y, z); pg.fill(ei.color); pg.ambientMaterial(ei.color); pg.specularMaterial(60); pg.shininess(20); let detail = isSnapshot ? 80 : (window.innerWidth < 768 ? 24 : 40); pg.sphere(ei.radius, detail, detail); if (showLabels) { pg.rotateY(-(rotY + autoRotationAngle)); pg.rotateX(-rotX); pg.translate(0, 0, ei.radius + 2); pg.fill(ei.textColor); pg.noLights(); pg.scale(1 / (zoom * sFactor)); pg.textSize(16 * zoom * sFactor); pg.textAlign(CENTER, CENTER); pg.text(atom.e, 0, 0); } pg.pop(); } pg.pop(); } function windowResized() { const c = document.getElementById('canvas-container'); if (c && c.offsetWidth > 0) resizeCanvas(c.offsetWidth, c.offsetHeight); } function setLanguage(lang) { currentLang = lang; const t = TRANSLATIONS[lang]; const s = (id, v) => { let e = document.getElementById(id); if (e) e.innerText = v; }; s('header-title', t.headerTitle); s('header-sub', t.headerSub); const ms = document.getElementById('molecule-select'); if (ms && ms.options.length > 0) ms.options[0].innerText = t.placeholder; updateButtonsText(); s('btn-save-image', t.btnSave); let ro = document.querySelector('#snap-res option[value="current"]'); if (ro) ro.innerText = t.resCurrent; let po = document.querySelector('#snap-format option[value="png"]'); if (po) po.innerText = t.fmtPNG; let jo = document.querySelector('#snap-format option[value="jpg"]'); if (jo) jo.innerText = t.fmtJPG; for (const [id, label] of Object.entries(t.optgroups)) { const el = document.getElementById(id); if (el) el.label = label; } } function updateButtonsText() { const t = TRANSLATIONS[currentLang]; let br = document.getElementById('toggle-rotate'); if (br) br.innerText = t.btnRotate; let bl = document.getElementById('toggle-labels'); if (bl) bl.innerText = t.btnLabels; } function calculateOptimalZoom(currentAtoms) { if (!currentAtoms || currentAtoms.length === 0) return 1.0; let minX=Infinity, maxX=-Infinity, minY=Infinity, maxY=-Infinity; for (let a of currentAtoms) { if (a.x < minX) minX = a.x; if (a.x > maxX) maxX = a.x; if (a.y < minY) minY = a.y; if (a.y > maxY) maxY = a.y; } if (minX === Infinity) return 1.5; let cw = (maxX - minX + 1.2) * SCALE; let ch = (maxY - minY + 1.2) * SCALE; return constrain(Math.min((width * 0.55) / cw, (height * 0.55) / ch), 0.3, 2.5); } function loadMolecule(type) { currentMoleculeKey = type; const data = MOLECULE_DATA[type]; if (data) { atoms = JSON.parse(JSON.stringify(data.atoms)); bonds = data.bonds; autoRotationAngle = 0; rotX = 0; rotY = 0; panX = 0; panY = 0; zoom = calculateOptimalZoom(atoms); if (window.innerWidth < 768) zoom *= 0.8; } } function captureImageDesktop() { performCapture( document.getElementById('snap-res').value, document.getElementById('snap-format').value ); } function captureImageMobile() { performCapture( document.getElementById('mobile-snap-res').value, document.getElementById('mobile-snap-format').value ); } function performCapture(resValue, formatValue) { const molName = currentMoleculeKey || 'molecule'; const ts = new Date().toISOString().replace(/[-:.]/g, ""); const filename = `${molName}_${ts}`; const isMobile = window.innerWidth <= 768; if (resValue === "current") { if (!isMobile) { saveCanvas(filename, formatValue); } else { const cv = document.getElementById('defaultCanvas0'); if (cv) cv.toBlob( b => showMobileSaveModal(b, filename, formatValue), `image/${formatValue === 'jpg' ? 'jpeg' : 'png'}` ); } } else { const dims = resValue.split('x'); let targetW = parseInt(dims[0]), targetH = parseInt(dims[1]); let pg = createGraphics(targetW, targetH, WEBGL); pg.pixelDensity(1); pg.textFont(myFont); renderScene(pg, targetW, targetH, targetH / height, true); if (!isMobile) { save(pg, filename + '.' + formatValue); pg.remove(); } else { pg.canvas.toBlob(b => { showMobileSaveModal(b, filename, formatValue); pg.remove(); }, `image/${formatValue === 'jpg' ? 'jpeg' : 'png'}`); } } } function showMobileSaveModal(blob, filename, ext) { const imageUrl = URL.createObjectURL(blob); const modal = document.createElement('div'); modal.style.cssText = 'position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,0.95);z-index:9999;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:20px;touch-action:auto;'; const img = document.createElement('img'); img.src = imageUrl; img.style.cssText = 'max-width:100%;max-height:65%;border:2px solid #555;border-radius:8px;margin-bottom:15px;pointer-events:auto;'; const ac = document.createElement('div'); ac.style.cssText = 'display:flex;gap:10px;flex-direction:column;width:100%;max-width:300px;'; const mkBtn = (txt, bg, fn) => { const b = document.createElement('button'); b.innerText = txt; b.style.cssText = `padding:12px;background:${bg};color:white;border:none;border-radius:8px;font-size:15px;font-weight:bold;cursor:pointer;`; b.onclick = fn; return b; }; if (navigator.canShare) { ac.appendChild(mkBtn('Chia sẻ / Lưu Ảnh (Khuyên dùng)', '#3794ff', async () => { try { const file = new File([blob], `${filename}.${ext}`, { type: blob.type }); if (navigator.canShare({ files: [file] })) { await navigator.share({ files: [file], title: 'Cấu trúc phân tử', text: `Phân tử ${filename}` }); } else { alert("Trình duyệt không hỗ trợ chia sẻ file. Dùng nút Tải xuống."); } } catch (e) { console.log(e); } })); } ac.appendChild(mkBtn('Tải xuống Tệp (Files)', '#28a745', () => { const a = document.createElement('a'); a.href = imageUrl; a.download = `${filename}.${ext}`; document.body.appendChild(a); a.click(); document.body.removeChild(a); alert("Đã bắt đầu tải xuống. Kiểm tra thư mục Downloads."); })); ac.appendChild(mkBtn('Đóng', '#444', () => { document.body.removeChild(modal); URL.revokeObjectURL(imageUrl); })); modal.appendChild(img); modal.appendChild(ac); document.body.appendChild(modal); } // ===================================================================== // DRAWING HELPERS // ===================================================================== function drawAromaticRing(pg, offsetX, offsetY) { const radius = 0.9 * SCALE; const dashCount = 8, gapRatio = 0.2; const segAngle = TWO_PI / dashCount; const drawAngle = segAngle * (1 - gapRatio); const stepsPerDash = 6, tubeR = 2.5; pg.fill(150); pg.specularMaterial(50); pg.noStroke(); for (let i = 0; i < dashCount; i++) { let st = i * segAngle; for (let j = 0; j < stepsPerDash; j++) { let t1 = st + (drawAngle * j / stepsPerDash); let t2 = st + (drawAngle * (j + 1) / stepsPerDash); drawCylinderBetweenPoints(pg, createVector(cos(t1)*radius + offsetX, sin(t1)*radius + offsetY, 0), createVector(cos(t2)*radius + offsetX, sin(t2)*radius + offsetY, 0), tubeR); } } } function drawCylinderBetweenPoints(pg, p1, p2, r) { let v = p5.Vector.sub(p2, p1); let len = v.mag(); if (len < 0.001) return; pg.push(); pg.translate((p1.x+p2.x)/2, (p1.y+p2.y)/2, (p1.z+p2.z)/2); let axis = createVector(0, 1, 0).cross(v); let angle = acos(constrain(createVector(0,1,0).dot(v.copy().normalize()), -1, 1)); if (axis.mag() > 0.001) pg.rotate(angle, axis); else if (v.y < 0) pg.rotateX(PI); pg.cylinder(r, len, 6, 1); pg.pop(); } function drawBondMulti(pg, p1, p2, order) { let dist = p1.dist(p2); if (dist < 0.1) return; pg.push(); pg.translate((p1.x+p2.x)/2, (p1.y+p2.y)/2, (p1.z+p2.z)/2); let v = p5.Vector.sub(p2, p1).normalize(); let yAxis = createVector(0, 1, 0); let axis = yAxis.cross(v); let angle = acos(constrain(yAxis.dot(v), -1, 1)); if (axis.mag() > 0.001) pg.rotate(angle, axis); else if (v.y < 0) pg.rotateX(PI); pg.fill(150); pg.specularMaterial(30); let bondR = 5, gap = 12; let detail = (window.innerWidth < 768) ? 12 : 24; if (order === 1) { pg.cylinder(bondR, dist, detail, 1); } else if (order === 2) { pg.push(); pg.translate(gap/2, 0, 0); pg.cylinder(bondR, dist, detail, 1); pg.pop(); pg.push(); pg.translate(-gap/2, 0, 0); pg.cylinder(bondR, dist, detail, 1); pg.pop(); } else if (order === 3) { pg.cylinder(bondR, dist, detail, 1); pg.push(); pg.translate(gap, 0, 0); pg.cylinder(bondR, dist, detail, 1); pg.pop(); pg.push(); pg.translate(-gap, 0, 0); pg.cylinder(bondR, dist, detail, 1); pg.pop(); } pg.pop(); } function draw() { if (isRotating) autoRotationAngle += 0.01; renderScene(this, width, height, 1); }