Class Vec2i


  • public final class Vec2i
    extends Object
    2D Vector based upon two integer components.
    • Constructor Detail

      • Vec2i

        public Vec2i()
      • Vec2i

        public Vec2i​(Vec2i o)
      • Vec2i

        public Vec2i​(int[] xy)
      • Vec2i

        public Vec2i​(int x,
                     int y)
    • Method Detail

      • copy

        public Vec2i copy()
      • set

        public void set​(Vec2i o)
        this = o, returns this.
      • set

        public void set​(int x,
                        int y)
        this = { x, y }, returns this.
      • set

        public Vec2i set​(int[] xy)
        this = xy, returns this.
      • get

        public int[] get​(int[] xy)
        xy = this, returns xy.
      • x

        public int x()
      • y

        public int y()
      • setX

        public void setX​(int x)
      • setY

        public void setY​(int y)
      • isZero

        public boolean isZero()
        Return true if all components are zero.
      • length

        public int length()
        Return the length of this vector, a.k.a the norm or magnitude
      • lengthSq

        public int lengthSq()
        Return the squared length of this vector, a.k.a the squared norm or squared magnitude
      • distSq

        public int distSq​(Vec2i o)
        Return the squared distance between this vector and the given one.

        When comparing the relative distance between two points it is usually sufficient to compare the squared distances, thus avoiding an expensive square root operation.

      • dist

        public int dist​(Vec2i o)
        Return the distance between this vector and the given one.
      • isEqual

        public boolean isEqual​(Vec2i o)
        Equals check.
        Parameters:
        o - comparison value
        Returns:
        true if all components are equal