Creative Technologies Lab | dokuWiki

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

User Tools

Site Tools


extras:codikon:p5js:kythera_berechnungshilfe

This is an old revision of the document!


let inputOD;
let buttonCalc;
let resultN;
let resultP;

function setup() {
  createCanvas(400, 200);

  // Eingabefeld für Außendurchmesser
  createP("Außendurchmesser des Zahnrads (mm):");
  inputOD = createInput("80"); 

  // Button
  buttonCalc = createButton("Berechnen");
  buttonCalc.mousePressed(calculateGear);

  // Ergebnisfelder
  resultN = createP("");
  resultP = createP("");
}

function calculateGear() {
  // Eingabe lesen
  let OD = float(inputOD.value());

  // Fester Diametral Pitch (wie in deinem funktionierenden Beispiel)
  let P = 1;

  // N berechnen
  let N = OD * P - 2;

  // runden, da N ganzzahlig sein muss
  let Nrounded = Math.round(N);

  // Ausgabe
  resultP.html("Diametral Pitch (P): " + P);
  resultN.html("Zähnezahl (N): " + Nrounded);
}

function draw() {
  background(240);
}
This website uses cookies. By using our website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website. Privacy Policy
/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