title: Calculate direction from dx, dy?
body: <p>I have a vessle that is traveling in a direction: </p>
  
  <pre><code>class Vessle{
      constructor() {
          this.position = {
              x: this.rnd(bound.width),
              y: this.rnd(bound.height),
              dx: this.rnd(5),
              dy: this.rnd(5)
          }
      }
      rnd(val) {return val * Math.random()}
      move(){
          this.position.x += this.position.dx;
          this.position.y += this.position.dy;    
      }
  }
  </code></pre>
  
  <p>When I draw it on a canvas I want to rotate the image so it's pointing in the traveling direction:</p>
  
  <pre><code>    drawImage(pos){
          let w = this.img.naturalWidth,
              h = this.img.naturalHeight
          this.ctx.save();
          this.ctx.translate(pos.x+w/2, pos.y+h/3);
          this.ctx.rotate(Math.atan(pos.dx,pos.dy));
          this.ctx.translate(-pos.x-w/2, -pos.y-h/3);
          this.ctx.drawImage(this.img, pos.x, pos.y);
          this.ctx.restore();
      }
  </code></pre>
  
  <p>This should be done in this line: </p>
  
  <pre><code>this.ctx.rotate(Math.atan(pos.dx,pos.dy));
  </code></pre>
  
  <p>They point in other directions in a to me inconsistent way(not like all of them pointing 90deg wrong etc)  I have the wrong units or something?</p>