Search in sources :

Example 6 with GVector

use of javax.vecmath.GVector in project jwt by emweb.

the class WebGLUtils method cross.

public static GVector cross(GVector v1, GVector v2) {
    assert (v1.getSize() == 3 && v2.getSize() == 3);
    GVector result = new GVector(3);
    result.setElement(0, v1.getElement(1) * v2.getElement(2) - v1.getElement(2) * v2.getElement(1));
    result.setElement(1, v1.getElement(2) * v2.getElement(0) - v1.getElement(0) * v2.getElement(2));
    result.setElement(2, v1.getElement(0) * v2.getElement(1) - v1.getElement(1) * v2.getElement(0));
    return result;
}
Also used : GVector(javax.vecmath.GVector)

Example 7 with GVector

use of javax.vecmath.GVector in project jwt by emweb.

the class WebGLUtils method multiply.

public static GVector multiply(GVector v, double scalar) {
    GVector result = new GVector(v.getSize());
    result.scale(scalar, v);
    return result;
}
Also used : GVector(javax.vecmath.GVector)

Example 8 with GVector

use of javax.vecmath.GVector in project jwt by emweb.

the class WebGLUtils method vec4ToVec3.

public static GVector vec4ToVec3(GVector v) {
    if (v.getSize() == 4) {
        GVector result = new GVector(3);
        double w = v.getElement(3);
        result.setElement(0, v.getElement(0) / w);
        result.setElement(1, v.getElement(1) / w);
        result.setElement(2, v.getElement(2) / w);
        return result;
    } else {
        assert (v.getSize() == 3);
        return v;
    }
}
Also used : GVector(javax.vecmath.GVector)

Example 9 with GVector

use of javax.vecmath.GVector in project jwt by emweb.

the class WebGLUtils method subtract.

public static GVector subtract(GVector v1, GVector v2) {
    if (v1.getSize() != v2.getSize()) {
        assert (v1.getSize() == 3 || v2.getSize() == 3);
        assert (v1.getSize() == 4 || v2.getSize() == 4);
        v1 = vec4ToVec3(v1);
        v2 = vec4ToVec3(v2);
    }
    GVector result = new GVector(v1.getSize());
    result.sub(v1, v2);
    return result;
}
Also used : GVector(javax.vecmath.GVector)

Example 10 with GVector

use of javax.vecmath.GVector in project jwt by emweb.

the class WebGLUtils method normalize.

public static GVector normalize(GVector v) {
    GVector result = new GVector(v.getSize());
    result.normalize(v);
    return result;
}
Also used : GVector(javax.vecmath.GVector)

Aggregations

GVector (javax.vecmath.GVector)13 GMatrix (javax.vecmath.GMatrix)4 Test (org.junit.Test)4