[DEV] update vector 2f
This commit is contained in:
parent
191705564f
commit
5519d703e0
@ -4,7 +4,6 @@ import org.atriasoft.etk.internal.Log;
|
|||||||
|
|
||||||
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
|
import edu.umd.cs.findbugs.annotations.CheckReturnValue;
|
||||||
|
|
||||||
@SuppressWarnings("preview")
|
|
||||||
public record Vector2f(
|
public record Vector2f(
|
||||||
float x,
|
float x,
|
||||||
float y) {
|
float y) {
|
||||||
@ -25,11 +24,11 @@ public record Vector2f(
|
|||||||
if (values.length == 1) {
|
if (values.length == 1) {
|
||||||
// no coma ...
|
// no coma ...
|
||||||
// in every case, we parse the first element :
|
// in every case, we parse the first element :
|
||||||
val1 = Float.valueOf(values[0]);
|
val1 = Float.parseFloat(values[0]);
|
||||||
val2 = val1;
|
val2 = val1;
|
||||||
} else {
|
} else {
|
||||||
val1 = Float.valueOf(values[0]);
|
val1 = Float.parseFloat(values[0]);
|
||||||
val2 = Float.valueOf(values[1]);
|
val2 = Float.parseFloat(values[1]);
|
||||||
}
|
}
|
||||||
return new Vector2f(val1, val2);
|
return new Vector2f(val1, val2);
|
||||||
}
|
}
|
||||||
@ -38,11 +37,6 @@ public record Vector2f(
|
|||||||
* **************************************************** Constructor
|
* **************************************************** Constructor
|
||||||
*****************************************************/
|
*****************************************************/
|
||||||
|
|
||||||
public Vector2f(final float x, final float y) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public static Vector2f clipInt(final Vector2f obj1) {
|
public static Vector2f clipInt(final Vector2f obj1) {
|
||||||
return new Vector2f((int) obj1.x, (int) obj1.y);
|
return new Vector2f((int) obj1.x, (int) obj1.y);
|
||||||
@ -192,7 +186,8 @@ public record Vector2f(
|
|||||||
public float get(final int index) {
|
public float get(final int index) {
|
||||||
if (index == 0) {
|
if (index == 0) {
|
||||||
return this.x;
|
return this.x;
|
||||||
} else if (index == 1) {
|
}
|
||||||
|
if (index == 1) {
|
||||||
return this.y;
|
return this.y;
|
||||||
}
|
}
|
||||||
throw new IllegalArgumentException("Unknown index: " + index);
|
throw new IllegalArgumentException("Unknown index: " + index);
|
||||||
@ -342,12 +337,12 @@ public record Vector2f(
|
|||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public Vector2f multiply(final float val) {
|
public Vector2f multiply(final float val) {
|
||||||
return new Vector2f(this.x * val, this.y * val);
|
return new Vector2f(this.x * val, this.y * val);
|
||||||
};
|
}
|
||||||
|
|
||||||
@CheckReturnValue
|
@CheckReturnValue
|
||||||
public Vector2f multiply(final Vector2f obj) {
|
public Vector2f multiply(final Vector2f obj) {
|
||||||
return new Vector2f(this.x * obj.x, this.y * obj.y);
|
return new Vector2f(this.x * obj.x, this.y * obj.y);
|
||||||
};
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalize this vector x^2 + y^2 = 1
|
* Normalize this vector x^2 + y^2 = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user