Upload files to "src/openonyx/utilities/internal"

This commit is contained in:
winterflyt committed 2026-11-30 06:18:28 +02:00
1 parent 93ed4082c3
commit c44f382556
5 files changed
+197

No files matched your search

@@ -0,0 +1,62 @@
package openonyx.utilities.internal;
import net.minecraft.util.Vec3;
import openonyx.utilities.VecUtils;
public class Plane3 {
private final Vec3 vec3;
private final Vec3 vec32;
public Vec3 L(LinearShape linearShape) {
Plane3 plane31 = this;
Double double_;
return (double_ = plane31.L(linearShape)) == null ? null : linearShape.L(double_);
}
public Double L(LinearShape linearShape) {
double d = this.vec3.dotProduct(this.vec32);
double e;
return LinearShape.L(e = linearShape.direction().dotProduct(this.vec32), 0.0) ? null : (d - linearShape.position().dotProduct(this.vec32)) / e;
}
public Vec3 getVec3() {
return this.vec3;
}
public Plane3(Vec3 vec3, Vec3 vec31) {
this.vec3 = vec3x;
this.vec32 = VecUtils.L(vec31);
}
public Vec3 getVec32() {
return this.vec32;
}
public static Plane3 d(Vec3 vec3, Vec3 vec31, Vec3 vec32) {
if (VecUtils.d(vec31 = vec31.crossProduct(vec32x).normalize())) {
throw new IllegalArgumentException("Points must not be on the same line");
} else {
return new Plane3(vec3x, vec31);
}
}
public static Plane3 L(Vec3 vec3, Vec3 vec31, Vec3 vec32) {
return d(vec3x, vec31.subtract(vec3x), vec32x.subtract(vec3x));
}
public Line3 L(Plane3 plane31) {
Plane3 plane32 = this;
Vec3 vec3x = plane31.vec32;
Vec3 vec31 = plane32.vec32;
double d;
Vec3 vec32x;
if (LinearShape.L(d = (vec32x = vec3x.crossProduct(vec31)).lengthSqr(), 0.0)) {
return null;
}
double e = vec3x.dotProduct(plane31.vec3);
double f = vec31.dotProduct(plane32.vec3);
Vec3 vec33 = vec31.crossProduct(vec32x).scale(e).add(vec32x.crossProduct(vec3x).scale(f)).scale(1.0 / d);
return new Line3(vec33, vec32x);
}
}
@@ -0,0 +1,6 @@
package openonyx.utilities.internal;
import net.minecraft.util.Vec3;
public record PointPair(Vec3 first, Vec3 second) {
}
+25
View File
@@ -0,0 +1,25 @@
package openonyx.utilities.internal;
import net.minecraft.util.Vec3;
public record Ray3(Vec3 origin, Vec3 direction) implements LinearShape {
@Override
public Vec3 position() {
return this.origin;
}
public static Ray3 L(Vec3 vec3, Vec3 vec31) {
return new Ray3(vec3, vec31.subtract(vec3));
}
@Override
public LineKind L() {
return LineKind.FORWARD;
}
public Ray3(Vec3 vec3, Vec3 vec31) {
LinearShape.L(direction);
this.origin = origin;
this.direction = direction;
}
}
@@ -0,0 +1,68 @@
package openonyx.utilities.internal;
import java.util.Arrays;
final class RingBuffer {
private double[] H;
private int e;
double L(int i) {
return this.H[i];
}
int L() {
return this.e;
}
void L() {
RingBuffer ringBuffer1 = this;
if (ringBuffer1.e > 1) {
for (int o = j = 1; o < ringBuffer1.e; o = j) {
double d = ringBuffer1.H[j];
int i;
for (int m = i = j; m > 0 && ringBuffer1.H[i - 1] > d; m = i) {
int p = i;
double f = ringBuffer1.H[i - 1];
i--;
ringBuffer1.H[p] = f;
}
j++;
ringBuffer1.H[i] = d;
}
int k = 1;
int l;
for (int n = l = 1; n < ringBuffer1.e; n = ++l) {
double ex;
if ((ex = ringBuffer1.H[l]) != ringBuffer1.H[k - 1]) {
ringBuffer1.H[k++] = ex;
}
}
ringBuffer1.e = k;
}
}
RingBuffer(int i) {
double[] d = new double[i];
boolean bl = true;
this.H = d;
}
void d(double d) {
if (Double.isFinite(d)) {
this.L(d);
}
}
void L(double d) {
if (this.e == this.H.length) {
this.H = Arrays.copyOf(this.H, Math.max(4, this.e * 2));
}
this.H[this.e++] = d;
}
}
@@ -0,0 +1,36 @@
package openonyx.utilities.internal;
import net.minecraft.util.Vec3;
import openonyx.utilities.VecUtils;
public record Segment3(Vec3 start, Vec3 end) implements LinearShape {
@Override
public LineKind L() {
return LineKind.SEGMENT_01;
}
public Segment3(Vec3 vec3, Vec3 vec31) {
if (VecUtils.d(end.subtract(start))) {
throw new IllegalArgumentException(
new StringBuilder().insert(0, "Line segment must not have zero length, actual: ").append(start).append(" -> ").append(end).toString()
);
}
this.start = start;
this.end = end;
}
@Override
public Vec3 position() {
return this.start;
}
public double L() {
return this.direction().length();
}
@Override
public Vec3 direction() {
return this.end.subtract(this.start);
}
}