Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1// Normalize path to include only M, L, C, and Z commands2export function normalize(segments) {3 const out = [];4 let lastType = '';5 let cx = 0, cy = 0;6 let subx = 0, suby = 0;7 let lcx = 0, lcy = 0;8 for (const { key, data } of segments) {9 switch (key) {10 case 'M':11 out.push({ key: 'M', data: [...data] });12 [cx, cy] = data;13 [subx, suby] = data;14 break;15 case 'C':16 out.push({ key: 'C', data: [...data] });17 cx = data[4];18 cy = data[5];19 lcx = data[2];20 lcy = data[3];21 break;22 case 'L':23 out.push({ key: 'L', data: [...data] });24 [cx, cy] = data;25 break;26 case 'H':27 cx = data[0];28 out.push({ key: 'L', data: [cx, cy] });29 break;30 case 'V':31 cy = data[0];32 out.push({ key: 'L', data: [cx, cy] });33 break;34 case 'S': {35 let cx1 = 0, cy1 = 0;36 if (lastType === 'C' || lastType === 'S') {37 cx1 = cx + (cx - lcx);38 cy1 = cy + (cy - lcy);39 }40 else {41 cx1 = cx;42 cy1 = cy;43 }44 out.push({ key: 'C', data: [cx1, cy1, ...data] });45 lcx = data[0];46 lcy = data[1];47 cx = data[2];48 cy = data[3];49 break;50 }51 case 'T': {52 const [x, y] = data;53 let x1 = 0, y1 = 0;54 if (lastType === 'Q' || lastType === 'T') {55 x1 = cx + (cx - lcx);56 y1 = cy + (cy - lcy);57 }58 else {59 x1 = cx;60 y1 = cy;61 }62 const cx1 = cx + 2 * (x1 - cx) / 3;63 const cy1 = cy + 2 * (y1 - cy) / 3;64 const cx2 = x + 2 * (x1 - x) / 3;65 const cy2 = y + 2 * (y1 - y) / 3;66 out.push({ key: 'C', data: [cx1, cy1, cx2, cy2, x, y] });67 lcx = x1;68 lcy = y1;69 cx = x;70 cy = y;71 break;72 }73 case 'Q': {74 const [x1, y1, x, y] = data;75 const cx1 = cx + 2 * (x1 - cx) / 3;76 const cy1 = cy + 2 * (y1 - cy) / 3;77 const cx2 = x + 2 * (x1 - x) / 3;78 const cy2 = y + 2 * (y1 - y) / 3;79 out.push({ key: 'C', data: [cx1, cy1, cx2, cy2, x, y] });80 lcx = x1;81 lcy = y1;82 cx = x;83 cy = y;84 break;85 }86 case 'A': {87 const r1 = Math.abs(data[0]);88 const r2 = Math.abs(data[1]);89 const angle = data[2];90 const largeArcFlag = data[3];91 const sweepFlag = data[4];92 const x = data[5];93 const y = data[6];94 if (r1 === 0 || r2 === 0) {95 out.push({ key: 'C', data: [cx, cy, x, y, x, y] });96 cx = x;97 cy = y;98 }99 else {100 if (cx !== x || cy !== y) {101 const curves = arcToCubicCurves(cx, cy, x, y, r1, r2, angle, largeArcFlag, sweepFlag);102 curves.forEach(function (curve) {103 out.push({ key: 'C', data: curve });104 });105 cx = x;106 cy = y;107 }108 }109 break;110 }111 case 'Z':112 out.push({ key: 'Z', data: [] });113 cx = subx;114 cy = suby;115 break;116 }117 lastType = key;118 }119 return out;120}121function degToRad(degrees) {122 return (Math.PI * degrees) / 180;123}124function rotate(x, y, angleRad) {125 const X = x * Math.cos(angleRad) - y * Math.sin(angleRad);126 const Y = x * Math.sin(angleRad) + y * Math.cos(angleRad);127 return [X, Y];128}129function arcToCubicCurves(x1, y1, x2, y2, r1, r2, angle, largeArcFlag, sweepFlag, recursive) {130 const angleRad = degToRad(angle);131 let params = [];132 let f1 = 0, f2 = 0, cx = 0, cy = 0;133 if (recursive) {134 [f1, f2, cx, cy] = recursive;135 }136 else {137 [x1, y1] = rotate(x1, y1, -angleRad);138 [x2, y2] = rotate(x2, y2, -angleRad);139 const x = (x1 - x2) / 2;140 const y = (y1 - y2) / 2;141 let h = (x * x) / (r1 * r1) + (y * y) / (r2 * r2);142 if (h > 1) {143 h = Math.sqrt(h);144 r1 = h * r1;145 r2 = h * r2;146 }147 const sign = (largeArcFlag === sweepFlag) ? -1 : 1;148 const r1Pow = r1 * r1;149 const r2Pow = r2 * r2;150 const left = r1Pow * r2Pow - r1Pow * y * y - r2Pow * x * x;151 const right = r1Pow * y * y + r2Pow * x * x;152 const k = sign * Math.sqrt(Math.abs(left / right));153 cx = k * r1 * y / r2 + (x1 + x2) / 2;154 cy = k * -r2 * x / r1 + (y1 + y2) / 2;155 f1 = Math.asin(parseFloat(((y1 - cy) / r2).toFixed(9)));156 f2 = Math.asin(parseFloat(((y2 - cy) / r2).toFixed(9)));157 if (x1 < cx) {158 f1 = Math.PI - f1;159 }160 if (x2 < cx) {161 f2 = Math.PI - f2;162 }163 if (f1 < 0) {164 f1 = Math.PI * 2 + f1;165 }166 if (f2 < 0) {167 f2 = Math.PI * 2 + f2;168 }169 if (sweepFlag && f1 > f2) {170 f1 = f1 - Math.PI * 2;171 }172 if (!sweepFlag && f2 > f1) {173 f2 = f2 - Math.PI * 2;174 }175 }176 let df = f2 - f1;177 if (Math.abs(df) > (Math.PI * 120 / 180)) {178 const f2old = f2;179 const x2old = x2;180 const y2old = y2;181 if (sweepFlag && f2 > f1) {182 f2 = f1 + (Math.PI * 120 / 180) * (1);183 }184 else {185 f2 = f1 + (Math.PI * 120 / 180) * (-1);186 }187 x2 = cx + r1 * Math.cos(f2);188 y2 = cy + r2 * Math.sin(f2);189 params = arcToCubicCurves(x2, y2, x2old, y2old, r1, r2, angle, 0, sweepFlag, [f2, f2old, cx, cy]);190 }191 df = f2 - f1;192 const c1 = Math.cos(f1);193 const s1 = Math.sin(f1);194 const c2 = Math.cos(f2);195 const s2 = Math.sin(f2);196 const t = Math.tan(df / 4);197 const hx = 4 / 3 * r1 * t;198 const hy = 4 / 3 * r2 * t;199 const m1 = [x1, y1];200 const m2 = [x1 + hx * s1, y1 - hy * c1];201 const m3 = [x2 + hx * s2, y2 - hy * c2];202 const m4 = [x2, y2];203 m2[0] = 2 * m1[0] - m2[0];204 m2[1] = 2 * m1[1] - m2[1];205 if (recursive) {206 return [m2, m3, m4].concat(params);207 }208 else {209 params = [m2, m3, m4].concat(params);210 const curves = [];211 for (let i = 0; i < params.length; i += 3) {212 const r1 = rotate(params[i][0], params[i][1], angleRad);213 const r2 = rotate(params[i + 1][0], params[i + 1][1], angleRad);214 const r3 = rotate(params[i + 2][0], params[i + 2][1], angleRad);215 curves.push([r1[0], r1[1], r2[0], r2[1], r3[0], r3[1]]);216 }217 return curves;218 }219}220 