summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Point3Temp.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/Point3Temp.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/Point3Temp.java')
-rw-r--r--NET/worlds/scape/Point3Temp.java168
1 files changed, 168 insertions, 0 deletions
diff --git a/NET/worlds/scape/Point3Temp.java b/NET/worlds/scape/Point3Temp.java
new file mode 100644
index 0000000..361b578
--- /dev/null
+++ b/NET/worlds/scape/Point3Temp.java
@@ -0,0 +1,168 @@
+package NET.worlds.scape;
+
+public class Point3Temp {
+ public float x;
+ public float y;
+ public float z;
+ private static Recycler recycler = new Recycler();
+
+ static {
+ nativeInit();
+ }
+
+ public static native void nativeInit();
+
+ public static Point3Temp make(float x, float y, float z) {
+ Point3Temp p = (Point3Temp)recycler.alloc();
+ if (p == null) {
+ recycler.recycle(new Point3Temp(0));
+ p = (Point3Temp)recycler.alloc();
+ }
+
+ p.x = x;
+ p.y = y;
+ p.z = z;
+ return p;
+ }
+
+ public static Point3Temp make() {
+ return make(0.0F, 0.0F, 0.0F);
+ }
+
+ public static Point3Temp make(Point3Temp p) {
+ return make(p.x, p.y, p.z);
+ }
+
+ protected Point3Temp(int dummy) {
+ }
+
+ public Point3Temp copy(Point3Temp b) {
+ this.set(b.x, b.y, b.z);
+ return this;
+ }
+
+ public void set(float _x, float _y, float _z) {
+ this.x = _x;
+ this.y = _y;
+ this.z = _z;
+ }
+
+ public float length() {
+ return (float)Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
+ }
+
+ public float squaredLength() {
+ return this.x * this.x + this.y * this.y + this.z * this.z;
+ }
+
+ public native Point3Temp times(Transform var1);
+
+ public native Point3Temp vectorTimes(Transform var1);
+
+ public Point3Temp normalize() {
+ float len = this.length();
+ if (len > 0.0F) {
+ this.dividedBy(len);
+ }
+
+ return this;
+ }
+
+ public Point3Temp negate() {
+ this.x = -this.x;
+ this.y = -this.y;
+ this.z = -this.z;
+ return this;
+ }
+
+ public Point3Temp abs() {
+ this.x = Math.abs(this.x);
+ this.y = Math.abs(this.y);
+ this.z = Math.abs(this.z);
+ return this;
+ }
+
+ public static Point3Temp getDirVector(float amount, float angle) {
+ angle = (float)(angle * (Math.PI / 180.0));
+ return make(-amount * (float)Math.sin(angle), amount * (float)Math.cos(angle), 0.0F);
+ }
+
+ public Point3Temp plus(Point3Temp p) {
+ this.x = this.x + p.x;
+ this.y = this.y + p.y;
+ this.z = this.z + p.z;
+ return this;
+ }
+
+ public Point3Temp cross(Point3Temp p) {
+ float xNew = this.y * p.z - this.z * p.y;
+ float yNew = this.z * p.x - this.x * p.z;
+ this.z = this.x * p.y - this.y * p.x;
+ this.x = xNew;
+ this.y = yNew;
+ return this;
+ }
+
+ public Point3Temp plus(float v) {
+ this.x += v;
+ this.y += v;
+ this.z += v;
+ return this;
+ }
+
+ public Point3Temp minus(float v) {
+ return this.plus(-v);
+ }
+
+ public Point3Temp minus(Point3Temp p) {
+ this.x = this.x - p.x;
+ this.y = this.y - p.y;
+ this.z = this.z - p.z;
+ return this;
+ }
+
+ public Point3Temp times(float v) {
+ this.x *= v;
+ this.y *= v;
+ this.z *= v;
+ return this;
+ }
+
+ public Point3Temp times(Point3Temp p) {
+ this.x = this.x * p.x;
+ this.y = this.y * p.y;
+ this.z = this.z * p.z;
+ return this;
+ }
+
+ public Point3Temp dividedBy(float v) {
+ this.x /= v;
+ this.y /= v;
+ this.z /= v;
+ return this;
+ }
+
+ public Point3Temp dividedBy(Point3Temp p) {
+ this.x = this.x / p.x;
+ this.y = this.y / p.y;
+ this.z = this.z / p.z;
+ return this;
+ }
+
+ public float dot(Point3Temp p) {
+ return p.x * this.x + p.y * this.y + p.z * this.z;
+ }
+
+ public float det(Point3Temp a, Point3Temp b) {
+ return this.x * a.y * b.z + a.x * b.y * this.z + b.x * this.y * a.z - this.z * a.y * b.x - a.z * b.y * this.x - b.z * this.y * a.x;
+ }
+
+ public boolean sameValue(Point3Temp p) {
+ return p == null ? false : this.x == p.x && this.y == p.y && this.z == p.z;
+ }
+
+ @Override
+ public String toString() {
+ return this.x + "," + this.y + "," + this.z;
+ }
+}