Creative Technologies Lab | dokuWiki

Repository of academic adventures, experimental technology, accidental brilliance, and collaborative nerdery.

User Tools

Site Tools


extras:codikon:p5js:kythera_berechnungshilfe

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

extras:codikon:p5js:kythera_berechnungshilfe [2025/11/26 09:13] – created Felix Hardmood Beckextras:codikon:p5js:kythera_berechnungshilfe [2025/11/26 09:19] (current) Felix Hardmood Beck
Line 1: Line 1:
 +Der untere p5.js-Sketch ermöglicht die schnelle Bestimmung der Zahnradparameter, die in [[..:anwendungssoftware:kythera|Kythera]] benötigt werden, um ein Zahnrad mit einem gewünschten Außendurchmesser zu erzeugen. Da Kythera keine direkte Durchmesserangabe zulässt und die Größe ausschließlich aus der Kombination von Zähnezahl (N) und Diametral Pitch (P) berechnet, übernimmt der Sketch genau diese Umrechnung: Aus einem eingegebenen Außendurchmesser in Millimetern wird automatisch die passende Zähnezahl für einen festgelegten Diametral Pitch berechnet. Damit lässt sich ohne manuelle Formelarbeit sofort ermitteln, welche Parameter in Kythera eingetragen werden müssen, um ein Zahnrad in der gewünschten Größe für den 3D-Druck oder die Weiterverarbeitung zu erzeugen.
 +
 +Das ganze liegt auch auf der ct-lab.info-Webseite: https://ct-lab.info/gear-math/
 +
 +=====P5.JS=====
  
 <code> <code>
Line 45: Line 50:
 } }
  
 +</code>
 +
 +
 +===== html =====
 +
 +
 +<code>
 +
 +<!doctype html>
 +<html lang="de">
 +<head>
 +  <meta charset="utf-8">
 +  <title>Zahnrad-Berechnung für Kythera</title>
 +  <meta name="viewport" content="width=device-width, initial-scale=1">
 +
 +  <!-- p5.js library -->
 +  <script src="https://cdn.jsdelivr.net/npm/p5@1.9.0/lib/p5.min.js"></script>
 +
 +  <style>
 +    body {
 +      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
 +      margin: 20px;
 +    }
 +    #canvas-container {
 +      margin-bottom: 20px;
 +    }
 +    label {
 +      display: inline-block;
 +      min-width: 260px;
 +    }
 +  </style>
 +</head>
 +<body>
 +
 +<h1>Zahnrad-Berechnung für Kythera</h1>
 +<p>
 +Gib einen gewünschten Außendurchmesser <strong>OD</strong> in Millimetern ein.  
 +Der Sketch berechnet daraus die benötigte Zähnezahl <strong>N</strong> für Kythera.  
 +Der Diametral Pitch <strong>P</strong> ist im Code auf <strong>1</strong> gesetzt (entspricht deinem aktuellen Workflow).
 +</p>
 +
 +<div id="canvas-container"></div>
 +
 +<div id="ui">
 +  <p>
 +    <label for="odInput">Außendurchmesser des Zahnrads (OD in mm):</label>
 +    <input id="odInput" type="number" value="80" step="0.1">
 +    <button id="calcButton">Berechnen</button>
 +  </p>
 +
 +  <p id="resultP"></p>
 +  <p id="resultN"></p>
 +  <p id="resultOD"></p>
 +</div>
 +
 +<script>
 +  // Fixed Diametral Pitch for Kythera.
 +  // If you want another value, change this constant.
 +  const FIXED_P = 1; // Diametral Pitch
 +
 +  let resultP, resultN, resultOD;
 +  let odInput, calcButton;
 +
 +  function setup() {
 +    // Small canvas; here only to satisfy p5.js. No drawing needed.
 +    const canvas = createCanvas(1, 1);
 +    canvas.parent("canvas-container");
 +    background(255);
 +
 +    // Get DOM elements that already exist in the HTML.
 +    odInput    = select("#odInput");
 +    calcButton = select("#calcButton");
 +    resultP    = select("#resultP");
 +    resultN    = select("#resultN");
 +    resultOD   = select("#resultOD");
 +
 +    calcButton.mousePressed(calculateGear);
 +
 +    // Initial calculation
 +    calculateGear();
 +  }
 +
 +  function draw() {
 +    // No continuous drawing required.
 +  }
 +
 +  function calculateGear() {
 +    // Read OD input (mm)
 +    const ODmm = parseFloat(odInput.value());
 +
 +    if (isNaN(ODmm) || ODmm <= 0) {
 +      resultP.html("Bitte einen Außendurchmesser &gt; 0 eingeben.");
 +      resultN.html("");
 +      resultOD.html("");
 +      return;
 +    }
 +
 +    const P = FIXED_P;
 +
 +    // Formula: OD = (N + 2) / P  (here used numerically in mm with P=1)
 +    // Solve for N: N = OD * P - 2
 +    const Nraw = ODmm * P - 2;
 +    const N = Math.round(Nraw); // N must be integer
 +
 +    // Recomputed OD based on rounded N
 +    const ODcalc = (N + 2) / P;
 +
 +    // Output
 +    resultP.html("Verwendeter Diametral Pitch (P): <strong>" + P.toFixed(3) + "</strong>");
 +    resultN.html("Berechnete Zähnezahl (N): <strong>" + N + "</strong> (vor Rundung: " + Nraw.toFixed(3) + ")");
 +    resultOD.html("Resultierender Außendurchmesser aus N und P: <strong>" + ODcalc.toFixed(3) + " mm</strong>");
 +  }
 +</script>
 +
 +</body>
 +</html>
 </code> </code>
/var/www/vhosts/ct-lab.info/wiki.ct-lab.info/data/attic/extras/codikon/p5js/kythera_berechnungshilfe.1764148387.txt.gz · Last modified: by Felix Hardmood Beck