# All files / src/WebGL/math Vector2.ts

100% Statements 12/12
100% Branches 4/4
100% Functions 5/5
100% Lines 12/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35

    172x
    172x

    1x
    1x

    1x

    1x
    1x

    1x

    1x
    1x

    1x

    1x

     // A 2 Vector
    export class Vector2 {
        x: number;
        y: number;

        constructor(x: number, y: number) {
          this.x = x || 0.0;
          this.y = y || 0.0;
        }

        set(x: any, y: any) {
          this.x = x;
          this.y = y;

          return this;
        }

        subVectors(a: { x: number; y: number; }, b: { x: number; y: number; }) {
          this.x = a.x - b.x;
          this.y = a.y - b.y;

          return this;
        }

        copy(v: { x: any; y: any; }) {
          this.x = v.x;
          this.y = v.y;

          return this;
        }

        clone() {
          return new Vector2(this.x, this.y);
        }
      }