Helmut Frühinsfeld: oder Mathematik ?

Beitrag lesen

var x=0;
      y=0;
      w=0;
      step=5000;
      r=80;

function Kreis() {
    w = w + 360/step;
    if(w > 360) w=0;
    x = Math.sin(w)*r + 220;
    y = Math.cos(w)*r + 220;
    deinlayer.moveTo(x,y);
    setTimeout('Kreis()',10);
  }

Hi,
da fehlt aber wieder das Umrechnen von Grad auf Rad! Ich würde noch eine Variable b einführen und dann mit    b=w*Math.pi/180 umrechnen; dann b statt w als Argument von sin und cos verwenden. Also so:

var x=0;
      y=0;
      w=0;
       b=0;       
       step=5000;
      r=80;

function Kreis() {
    w = w + 360/step;
    if(w > 360) w=0;
    b=w*Math.pi/180;
     x = Math.sin(b)*r + 220;
    y = Math.cos(b)*r + 220;
    deinlayer.moveTo(x,y);
    setTimeout('Kreis()',10);
  }

Ciao
Helmut