vector33

It is made for homework

Usage no npm install needed!

<script type="module">
  import vector33 from 'https://cdn.skypack.dev/vector33';
</script>

README

it is made for homework

Introducton

npm intall vector33

Use vector33

file : vector33.js

class Vector {
  constructor(x,y) {
        this.x = x; 
        this.y = y;
  }
  
  add(v2) { 
    return new Vector(this.x+v2.x,this.y+v2.y)
   }
   sub(v2) { 
    return new Vector(this.x-v2.x,this.y-v2.y)
   }
   dot(v2) { 
    return new Vector(this.x*v2.x,this.y*v2.y)
     }
   neg() { 
    return new Vector(-this.x,-this.y)
    }

  toString() { 
        return "("+this.x+","+this.y+")"
    }

}

module.exports = Vector;