If you think the Android project fun-gl listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
package com.jcxavier.android.opengl.math;
//www.java2s.com/**
* Created on 12/03/2014.
*
* @author Joo Xavier <jcxavier@jcxavier.com>
*/publicfinalclass Vector4 implements IVector<Vector4> {
publicfloat x;
publicfloat y;
publicfloat z;
publicfloat w;
public Vector4() {
x = 0;
y = 0;
z = 0;
w = 0;
}
public Vector4(finalfloat x, finalfloat y, finalfloat z, finalfloat w) {
set(x, y, z, w);
}
public Vector4(final Vector4 v) {
set(v);
}
@Override
public Vector4 set(final Vector4 v) {
x = v.x;
y = v.y;
z = v.z;
w = v.w;
returnthis;
}
public Vector4 set(finalfloat x, finalfloat y, finalfloat z, finalfloat w) {
this.x = x;
this.y = y;
this.z = z;
this.w = w;
returnthis;
}
@Override
public Vector4 add(final Vector4 v) {
return set(x + v.x, y + v.y, z + v.z, w + v.w);
}
@Override
public Vector4 sub(final Vector4 v) {
return set(x - v.x, y - v.y, z - v.z, w - v.w);
}
@Override
public Vector4 negate() {
return set(-x, -y, -z, -w);
}
}