Skip to content
Snippets Groups Projects
Select Git revision
  • 88717862a3ea8a1bf88267ad718298bb17a0b920
  • master default protected
  • extended_loader_api_no_scifio
  • extended_loader_api
  • plugin_support
  • kd-tree
  • basic_app
7 results

V2i.java

Blame
  • V2i.java 1.03 KiB
    package azgracompress.data;
    
    public class V2i {
        private final int x;
        private final int y;
    
        public V2i(final int x, final int y) {
            this.x = x;
            this.y = y;
        }
    
        public V2i(final int universalValue) {
            this(universalValue, universalValue);
        }
    
        public int getX() {
            return x;
        }
    
        public int getY() {
            return y;
        }
    
    
        public V2i add(final V2i other) {
            return new V2i(x + other.x, y + other.y);
        }
    
        public V2i sub(final V2i other) {
            return new V2i(x - other.x, y - other.y);
        }
    
        @Override
        public String toString() {
            return String.format("[%d;%d]", x, y);
        }
    
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof V2i) {
                final V2i other = (V2i) obj;
                return ((x == other.x) && (y == other.y));
            } else {
                return super.equals(obj);
            }
    
        }
    
        public V2l toV2l() {
            return new V2l(x, y);
        }
    
        public V3i toV3i() {
            return new V3i(x, y, 1);
        }
    }