All Downloads are FREE. Search and download functionalities are using the official Maven repository.

darwin.util.math.base.vector.Vector Maven / Gradle / Ivy

/*
 * Copyright (C) 2012 daniel
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a clone of the GNU General Public License
 * along with this program.  If not, see .
 */
package darwin.util.math.base.vector;

/**
 *
 * @author daniel
 */
public abstract class Vector> extends ImmutableVector {

    public abstract E add(ImmutableVector b);

    public abstract E add(float b);

    public abstract E sub(ImmutableVector b);

    public abstract E sub(float b);

    public abstract E mul(ImmutableVector b);

    public abstract E mul(float b);

    public abstract E div(ImmutableVector b);

    public abstract E div(float b);

    public abstract E min(ImmutableVector b);

    public abstract E min(float b);

    public abstract E max(ImmutableVector b);

    public abstract E max(float b);

    public abstract E rotateCCW(int axis);

    public abstract E rotateCW(int axis);

    public E reflect(ImmutableVector normal) {
        E n = normal.clone();
        n.mul(dot(n) * 2);
        sub(n);
        return (E) this;
    }

    public E normalize() {
        float len = (float) length();
        if (len != 0) {
            mul(1f / len);
        }
        return (E) this;
    }

    public E invert() {
        return (E) mul(-1);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy