[DEV] add reflect calculation
This commit is contained in:
parent
6028c42d0d
commit
84f92a1841
@ -70,6 +70,10 @@ public record Vector2b(
|
|||||||
|
|
||||||
public static final Vector2b FALSE = new Vector2b(false, false);
|
public static final Vector2b FALSE = new Vector2b(false, false);
|
||||||
public static final Vector2b TRUE = new Vector2b(true, true);
|
public static final Vector2b TRUE = new Vector2b(true, true);
|
||||||
|
public static final Vector2b FALSE_FALSE = FALSE;
|
||||||
|
public static final Vector2b TRUE_TRUE = TRUE;
|
||||||
|
public static final Vector2b TRUE_FALSE = new Vector2b(true, false);
|
||||||
|
public static final Vector2b FALSE_TRUE = new Vector2b(false, true);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
@ -176,7 +176,8 @@ public record Vector3f(
|
|||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public Vector3f divide(final float val) {
|
public Vector3f divide(final float val) {
|
||||||
if (val != 0.0f) {
|
if (val != 0.0f) {
|
||||||
return new Vector3f(this.x / val, this.y / val, this.z / val);
|
float tmp = 1.0f / val;
|
||||||
|
return new Vector3f(this.x * tmp, this.y * tmp, this.z * tmp);
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("divice by 0 (vector3f)");
|
throw new IllegalArgumentException("divice by 0 (vector3f)");
|
||||||
}
|
}
|
||||||
@ -307,6 +308,16 @@ public record Vector3f(
|
|||||||
return new Vector3f(-this.x, -this.y, -this.z);
|
return new Vector3f(-this.x, -this.y, -this.z);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reflect the current vector with the input normal
|
||||||
|
* @param normal Normal to reflect on
|
||||||
|
* @return the new reflect vector
|
||||||
|
*/
|
||||||
|
@CheckReturnValue
|
||||||
|
public Vector3f reflect(Vector3f normal) {
|
||||||
|
return this.less(normal.multiply(this.dot(normal) * 2.0f));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In-Equality compare operator with an other object.
|
* In-Equality compare operator with an other object.
|
||||||
* @param obj Reference on the comparing object
|
* @param obj Reference on the comparing object
|
||||||
@ -556,6 +567,9 @@ public record Vector3f(
|
|||||||
*/
|
*/
|
||||||
public static final Vector3f ZERO = new Vector3f(0, 0, 0);
|
public static final Vector3f ZERO = new Vector3f(0, 0, 0);
|
||||||
public static final Vector3f ONE = new Vector3f(1, 1, 1);
|
public static final Vector3f ONE = new Vector3f(1, 1, 1);
|
||||||
|
public static final Vector3f ONE_X = new Vector3f(1, 0, 0);
|
||||||
|
public static final Vector3f ONE_Y = new Vector3f(0, 1, 0);
|
||||||
|
public static final Vector3f ONE_Z = new Vector3f(0, 0, 1);
|
||||||
public static final Vector3f MAX = new Vector3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
|
public static final Vector3f MAX = new Vector3f(Float.MAX_VALUE, Float.MAX_VALUE, Float.MAX_VALUE);
|
||||||
public static final Vector3f MIN = new Vector3f(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);
|
public static final Vector3f MIN = new Vector3f(-Float.MAX_VALUE, -Float.MAX_VALUE, -Float.MAX_VALUE);
|
||||||
public static final Vector3f VALUE_2 = new Vector3f(2, 2, 2);
|
public static final Vector3f VALUE_2 = new Vector3f(2, 2, 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user