06 - Unit Vector, Dot Product/script.js
//returns a vector with same direction and 1 length

returns a vector with same direction and 1 length
returns a vector with same direction and 1 length
unit(){
        if(this.mag() === 0){
            return new Vector(0,0);
        } else {
            return new Vector(this.x/this.mag(), this.y/this.mag());
        }
    }
unit ( ) { if ( this . mag ( ) === 0 ) { return new Vector ( 0 , 0 ) ; } else { return new Vector ( this . x / this . mag ( ) , this . y / this . mag ( ) ) ; } }
returns a vector with same direction and 1 length
returns a vector with same direction and 1 length