From 93ed4082c3baf9abc8d1191e703ca05d963718eb Mon Sep 17 00:00:00 2001 From: winterflyt <36+winterflyt@noreply.skidsolutions.xyz> Date: Mon, 30 Nov 2026 06:18:14 +0200 Subject: [PATCH] Upload files to "src/openonyx/utilities/internal" --- src/openonyx/utilities/internal/Box3.java | 238 ++++++++++++ .../utilities/internal/ClosestPoint.java | 6 + src/openonyx/utilities/internal/Line3.java | 24 ++ src/openonyx/utilities/internal/LineKind.java | 86 +++++ .../utilities/internal/LinearShape.java | 354 ++++++++++++++++++ 5 files changed, 708 insertions(+) create mode 100644 src/openonyx/utilities/internal/Box3.java create mode 100644 src/openonyx/utilities/internal/ClosestPoint.java create mode 100644 src/openonyx/utilities/internal/Line3.java create mode 100644 src/openonyx/utilities/internal/LineKind.java create mode 100644 src/openonyx/utilities/internal/LinearShape.java diff --git a/src/openonyx/utilities/internal/Box3.java b/src/openonyx/utilities/internal/Box3.java new file mode 100644 index 0000000..c7de05d --- /dev/null +++ b/src/openonyx/utilities/internal/Box3.java @@ -0,0 +1,238 @@ +package openonyx.utilities.internal; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.ThreadLocalRandom; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraft.util.Vec3i; +import openonyx.utilities.BoxUtils; +import openonyx.utilities.VecUtils; + +public class Box3 { + private final Vec3 vec3; + private final Vec3 vec32; + + public Box3 L(Vec3i vec3i) { + return new Box3(this.vec32.add(vec3i.getX(), vec3i.getY(), vec3i.getZ()), this.vec3.add(vec3i.getX(), vec3i.getY(), vec3i.getZ())); + } + + private Vec3[] L() { + Box3 box31 = this; + Vec3 vec3x; + if (LinearShape.L((vec3x = box31.L()).xCoord, 0.0)) { + Vec3[] vec3s1 = new Vec3[2]; + boolean bl1 = true; + boolean bl3 = false; + vec3s1[0] = new Vec3(0.0, vec3x.yCoord, 0.0); + vec3s1[1] = new Vec3(0.0, 0.0, vec3x.zCoord); + return vec3s1; + } else if (LinearShape.L(vec3x.yCoord, 0.0)) { + Vec3[] vec3s = new Vec3[2]; + boolean bl = true; + vec3s[0] = new Vec3(vec3x.xCoord, 0.0, 0.0); + vec3s[1] = new Vec3(0.0, 0.0, vec3x.zCoord); + return vec3s; + } else if (LinearShape.L(vec3x.zCoord, 0.0)) { + Vec3[] vec3s2 = new Vec3[2]; + boolean bl2 = true; + vec3s2[0] = new Vec3(0.0, vec3x.yCoord, 0.0); + vec3s2[1] = new Vec3(vec3x.xCoord, 0.0, 0.0); + return vec3s2; + } else { + throw new IllegalStateException( + new StringBuilder().insert(0, "Face must be axis aligned for this function to work. dimensions=").append(vec3x).toString() + ); + } + } + + public Box3 L() { + return LinearShape.L(this.L(), 0.0) ? null : this; + } + + public Box3(Vec3 vec3, Vec3 vec31) { + this.vec32 = new Vec3(Math.min(vec3x.xCoord, vec31.xCoord), Math.min(vec3x.yCoord, vec31.yCoord), Math.min(vec3x.zCoord, vec31.zCoord)); + this.vec3 = new Vec3(Math.max(vec3x.xCoord, vec31.xCoord), Math.max(vec3x.yCoord, vec31.yCoord), Math.max(vec3x.zCoord, vec31.zCoord)); + } + + public Vec3 I() { + Box3 box31 = this; + ThreadLocalRandom threadLocalRandom = ThreadLocalRandom.current(); + Vec3 vec3x = new Vec3; + double e; + Box3 box32; + if (box31.vec32.xCoord == box31.vec3.xCoord) { + e = box31.vec32.xCoord; + box32 = box31; + } else { + e = threadLocalRandom.nextDouble(box31.vec32.xCoord, box31.vec3.xCoord); + box32 = box31; + } + + double d; + Box3 box33; + if (box32.vec32.yCoord == box31.vec3.yCoord) { + d = box31.vec32.yCoord; + box33 = box31; + } else { + d = threadLocalRandom.nextDouble(box31.vec32.yCoord, box31.vec3.yCoord); + box33 = box31; + } + + vec3x./* $VF: Unable to resugar constructor */( + e, d, box33.vec32.zCoord == box31.vec3.zCoord ? box31.vec32.zCoord : threadLocalRandom.nextDouble(box31.vec32.zCoord, box31.vec3.zCoord) + ); + return vec3x; + } + + public Vec3 getVec3() { + return this.vec3; + } + + public Plane3 L() { + Box3 box31 = this; + Vec3[] vec3s = box31.L(); + return Plane3.d(box31.vec32, vec3s[0], vec3s[1]); + } + + public Box3 L(double d) { + return new Box3( + new Vec3(this.vec32.xCoord, Math.max(this.vec32.yCoord, d), this.vec32.zCoord), + new Vec3(this.vec3.xCoord, Math.max(this.vec3.yCoord, d), this.vec3.zCoord) + ); + } + + public Box3 L(Vec3 vec3) { + return new Box3(this.vec32.add(vec3x), this.vec3.add(vec3x)); + } + + public Box3 L(AxisAlignedBB axisAlignedBB) { + return new Box3(BoxUtils.L(axisAlignedBB, this.vec32), BoxUtils.L(axisAlignedBB, this.vec3)); + } + + public Vec3 getVec32() { + return this.vec32; + } + + public Vec3 L(LinearShape linearShape) { + Box3 box31 = this; + Vec3[] vec3s = box31.L(); + Plane3 plane3 = Plane3.d(box31.vec32, vec3s[0], vec3s[1]); + List list = box31.L(); + Vec3 vec32x = plane3.L(linearShape); + Vec3 vec3x = box31.d(); + if (vec32x != null) { + boolean bl = true; + Iterator iterator = list.iterator(); + + while (true) { + List list1; + if (iterator.hasNext()) { + Vec3 vec34 = ((Segment3)iterator.next()).d(0.5); + Vec3 vec31 = vec34.subtract(vec3x); + if (!(vec34.subtract(vec32x).dotProduct(vec31) <= 0.0)) { + continue; + } + + bl = false; + list1 = list; + } else { + list1 = list; + } + + if (list1.isEmpty() || bl) { + return vec32x; + } + break; + } + } + + Vec3 vec33 = null; + double e = Double.POSITIVE_INFINITY; + Iterator iterator1 = list.iterator(); + + label39: + while (true) { + for (Iterator iterator2 = iterator1; iterator2.hasNext(); iterator2 = iterator1) { + PointPair pointPair; + if ((pointPair = ((Segment3)iterator1.next()).L(linearShape)) != null) { + double d; + if ((d = pointPair.first().distanceToSqr(pointPair.second())) < e) { + e = d; + vec33 = pointPair.first(); + } + continue label39; + } + } + + if (vec33 != null) { + return vec33; + } + + if (vec32x != null) { + return vec32x; + } + + return vec3x; + } + } + + public Vec3 d() { + return this.vec32.lerp(this.vec3, 0.5); + } + + private List L() { + Box3 box31 = this; + ArrayList arrayList = new ArrayList(4); + Vec3[] vec3s; + if (!VecUtils.d((vec3s = box31.L())[0])) { + arrayList.add(new Segment3(box31.vec32, box31.vec32.add(vec3s[0]))); + arrayList.add(new Segment3(box31.vec3, box31.vec3.subtract(vec3s[0]))); + } + + if (!VecUtils.d(vec3s[1])) { + arrayList.add(new Segment3(box31.vec32, box31.vec32.add(vec3s[1]))); + arrayList.add(new Segment3(box31.vec3, box31.vec3.subtract(vec3s[1]))); + } + + return arrayList; + } + + public double L() { + Box3 box31 = this; + Vec3 vec3x; + return (vec3x = box31.L()).xCoord * vec3x.yCoord + vec3x.yCoord * vec3x.zCoord + vec3x.xCoord * vec3x.zCoord; + } + + public Segment3 L(LinearShape linearShape) { + Box3 box31 = this; + ArrayList arrayList = new ArrayList(4); + Iterator iterator; + Iterator iterator1 = iterator = box31.L().iterator(); + + while (iterator1.hasNext()) { + Segment3 segment3 = (Segment3)iterator.next(); + PointPair pointPair; + if ((pointPair = linearShape.L(segment3)) == null) { + iterator1 = iterator; + } else { + arrayList.add(new ClosestPoint(pointPair.second(), pointPair.second().distanceToSqr(pointPair.first()))); + iterator1 = iterator; + } + } + + arrayList.sort((closestPoint, closestPoint1) -> Double.compare(closestPoint.distanceSquared(), closestPoint1.distanceSquared())); + if (arrayList.size() < 2) { + return null; + } + + Vec3 vec3x = ((ClosestPoint)arrayList.get(0)).point(); + Vec3 vec31; + return VecUtils.d((vec31 = ((ClosestPoint)arrayList.get(1)).point()).subtract(vec3x)) ? null : new Segment3(vec3x, vec31); + } + + public Vec3 L() { + return new Vec3(this.vec3.xCoord - this.vec32.xCoord, this.vec3.yCoord - this.vec32.yCoord, this.vec3.zCoord - this.vec32.zCoord); + } +} diff --git a/src/openonyx/utilities/internal/ClosestPoint.java b/src/openonyx/utilities/internal/ClosestPoint.java new file mode 100644 index 0000000..617e12a --- /dev/null +++ b/src/openonyx/utilities/internal/ClosestPoint.java @@ -0,0 +1,6 @@ +package openonyx.utilities.internal; + +import net.minecraft.util.Vec3; + +public record ClosestPoint(Vec3 point, double distanceSquared) { +} diff --git a/src/openonyx/utilities/internal/Line3.java b/src/openonyx/utilities/internal/Line3.java new file mode 100644 index 0000000..a6cf662 --- /dev/null +++ b/src/openonyx/utilities/internal/Line3.java @@ -0,0 +1,24 @@ +package openonyx.utilities.internal; + +import net.minecraft.util.Vec3; + +public record Line3(Vec3 position, Vec3 direction) implements LinearShape { + public Line3(Vec3 vec3, Vec3 vec31) { + LinearShape.L(direction); + this.position = position; + this.direction = direction; + } + + @Override + public LineKind L() { + return LineKind.UNBOUNDED; + } + + public Vec3 position2() { + return this.position; + } + + public static Line3 L(Vec3 vec3, Vec3 vec31) { + return new Line3(vec3, vec31.subtract(vec3)); + } +} diff --git a/src/openonyx/utilities/internal/LineKind.java b/src/openonyx/utilities/internal/LineKind.java new file mode 100644 index 0000000..017c2a8 --- /dev/null +++ b/src/openonyx/utilities/internal/LineKind.java @@ -0,0 +1,86 @@ +package openonyx.utilities.internal; + +public enum LineKind { + UNBOUNDED(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), + SEGMENT_01(0.0, 1.0), + FORWARD(0.0, Double.POSITIVE_INFINITY); + + private static final double[] h; + private static final double[] l; + private static final double[] I; + private final double i; + private final double e; + + public double d() { + return this.i; + } + + public double D(double d) { + if (!Double.isFinite(d)) { + return Double.NaN; + } else { + return !(d < this.e - 1.0E-9) && !(d > this.i + 1.0E-9) ? this.L(d) : Double.NaN; + } + } + + public double[] L() { + switch (this) { + case UNBOUNDED: + while (false) { + } + + return h; + case SEGMENT_01: + return I; + case FORWARD: + return l; + default: + throw new MatchException(null, null); + } + } + + LineKind(double d, double e) { + this.e = d; + this.i = ex; + } + + public double d(double d) { + return !Double.isFinite(d) ? Double.NaN : this.L(d); + } + + private double L(double d) { + if (d < this.e) { + return this.e; + } else { + return d > this.i ? this.i : d; + } + } + + private static LineKind[] L() { + LineKind[] lineKinds = new LineKind[3]; + boolean bl = true; + lineKinds[0] = UNBOUNDED; + lineKinds[1] = FORWARD; + lineKinds[2] = SEGMENT_01; + return lineKinds; + } + + static { + double[] d = new double[0]; + boolean bl = true; + h = d; + d = new double[1]; + bl = true; + d[0] = 0.0; + I = d; + d = new double[2]; + bl = true; + d[0] = 0.0; + d[1] = 1.0; + l = d; + } + + public double L() { + return this.e; + } +} diff --git a/src/openonyx/utilities/internal/LinearShape.java b/src/openonyx/utilities/internal/LinearShape.java new file mode 100644 index 0000000..bed3528 --- /dev/null +++ b/src/openonyx/utilities/internal/LinearShape.java @@ -0,0 +1,354 @@ +package openonyx.utilities.internal; + +import java.util.function.DoubleConsumer; +import net.minecraft.util.AxisAlignedBB; +import net.minecraft.util.Vec3; +import net.minecraft.util.EnumFacing.Axis; +import openonyx.utilities.BoxUtils; +import openonyx.utilities.VecUtils; + +public interface LinearShape { + double e = 1.0E-9; + + static void L(Vec3 vec3) { + if (VecUtils.d(vec3)) { + throw new IllegalArgumentException(new StringBuilder().insert(0, "Direction should be not zero, actual: ").append(vec3).toString()); + } + } + + default ClosestPoint L(AxisAlignedBB axisAlignedBB) { + LinearShape linearShape1 = this; + Vec3 vec31 = linearShape1.position(); + Vec3 vec3 = linearShape1.direction(); + double d = vec31.xCoord; + double ex = vec31.yCoord; + double f = vec31.zCoord; + double h = vec3.xCoord; + double i = vec3.yCoord; + double j = vec3.zCoord; + RingBuffer ringBuffer = new RingBuffer(6); + if (!L(h, 0.0)) { + ringBuffer.d((axisAlignedBB.minX - d) / h); + ringBuffer.d((axisAlignedBB.maxX - d) / h); + } + + if (!L(i, 0.0)) { + ringBuffer.d((axisAlignedBB.minY - ex) / i); + ringBuffer.d((axisAlignedBB.maxY - ex) / i); + } + + if (!L(j, 0.0)) { + ringBuffer.d((axisAlignedBB.minZ - f) / j); + ringBuffer.d((axisAlignedBB.maxZ - f) / j); + } + + ringBuffer.L(); + LineKind lineKind = linearShape1.L(); + double[] z = new double[2]; + boolean bl = true; + z[0] = Double.NaN; + z[1] = Double.POSITIVE_INFINITY; + double[] k = z; + DoubleConsumer doubleConsumer = bi -> { + if (!Double.isNaN(bi = lineKind.D(bi))) { + d += h * bi; + h = ex + i * bi; + ex = f + j * bi; + d = BoxUtils.L(axisAlignedBB, d, h, ex); + if (Double.isNaN(k[0]) || d < k[1] - 1.0E-9) { + k[0] = bi; + k[1] = d; + } + } + }; + double[] g; + int n = (g = lineKind.L()).length; + + int l; + for (int u = l = 0; u < n; u = l) { + double ba = g[l]; + l++; + doubleConsumer.accept(ba); + } + + for (int v = s = 0; v < ringBuffer.L(); v = s) { + doubleConsumer.accept(ringBuffer.L(s++)); + } + + RingBuffer ringBuffer1 = new RingBuffer(8); + + for (int w = o = 0; w < ringBuffer.L(); w = o) { + L(ringBuffer1, lineKind, ringBuffer.L(o++)); + } + + double[] p; + l = (p = lineKind.L()).length; + + for (int x = q = 0; x < l; x = q) { + double m = p[q]; + q++; + L(ringBuffer1, lineKind, m); + } + + ringBuffer1.L(); + d = lineKind.L(); + + for (int y = r = 0; y < ringBuffer1.L(); y = r) { + double t = ringBuffer1.L(r); + r++; + L(axisAlignedBB, lineKind, d, t, vec31, vec3, doubleConsumer); + d = t; + } + + L(axisAlignedBB, lineKind, d, lineKind.d(), vec31, vec3, doubleConsumer); + if (Double.isNaN(k[0])) { + doubleConsumer.accept(0.0); + } + + if (Double.isNaN(k[0])) { + throw new IllegalStateException(new StringBuilder().insert(0, "Unable to find nearest point on geometry ").append(linearShape1).toString()); + } else { + return new ClosestPoint(linearShape1.d(k[0]), k[1]); + } + } + + private double L(double[] d) { + LinearShape linearShape1 = this; + LineKind lineKind = linearShape1.L(); + double ex = d[0]; + double f = d[1]; + double g = Math.max(ex, lineKind.L()); + boolean bl = Double.isFinite(lineKind.L()) && lineKind.L() > ex + 1.0E-9 && lineKind.L() < f - 1.0E-9; + return bl ? lineKind.D(f) : lineKind.D(g); + } + + Vec3 position(); + + default Vec3 d(double d) { + return VecUtils.L(this.position(), d, this.direction()); + } + + LineKind L(); + + private static void L(RingBuffer ringBuffer, LineKind lineKind, double d) { + if (!(d < lineKind.L() - 1.0E-9) && !(d > lineKind.d() + 1.0E-9)) { + ringBuffer.L(d); + } + } + + default Vec3 L(AxisAlignedBB axisAlignedBB) { + double[] ex; + if ((ex = this.L(axisAlignedBB)) == null) { + return null; + } + + double d; + return Double.isNaN(d = this.L(ex)) ? null : this.L(d); + } + + private double[] L(AxisAlignedBB axisAlignedBB) { + LinearShape linearShape1 = this; + Vec3 vec31 = linearShape1.position(); + Vec3 vec3 = linearShape1.direction(); + double d = Double.NEGATIVE_INFINITY; + double ex = Double.POSITIVE_INFINITY; + Axis[] axis1; + int i = (axis1 = Axis.values()).length; + + int j; + for (int m = j = 0; m < i; m = ++j) { + Axis axis = axis1[j]; + double f = vec31.get(axis); + double g = vec3.get(axis); + double h = axisAlignedBB.min(axis); + double k = axisAlignedBB.max(axis); + if (L(g, 0.0)) { + if (f < h || f > k) { + return null; + } + } else { + h = (h - f) / g; + f = (k - f) / g; + d = Math.max(d, Math.min(h, f)); + ex = Math.min(ex, Math.max(h, f)); + if (d > ex + 1.0E-9) { + return null; + } + } + } + + LineKind lineKind = linearShape1.L(); + if (!(ex < lineKind.L() - 1.0E-9) && !(d > lineKind.d() + 1.0E-9)) { + double[] l = new double[2]; + boolean bl = true; + l[0] = d; + l[1] = ex; + return l; + } else { + return null; + } + } + + default double d(Vec3 vec3) { + return this.L(vec3).distanceToSqr(vec3); + } + + default Vec3 L(Vec3 vec3) { + double d; + if (Double.isNaN(d = this.L().d(this.L(vec3)))) { + throw new IllegalStateException(new StringBuilder().insert(0, "Unable to project point ").append(vec3).append(" on geometry ").append(this).toString()); + } else { + return this.d(d); + } + } + + private static void L(double[] d, LineKind lineKind, LineKind lineKind1, Vec3 vec3, Vec3 vec31, double e, double f, double g, double h, double i) { + h = lineKind.D(h); + i = lineKind1.D(i); + if (!Double.isNaN(h) && !Double.isNaN(i)) { + ex = ex + vec3.xCoord * h - vec31.xCoord * i; + f = f + vec3.yCoord * h - vec31.yCoord * i; + g = g + vec3.zCoord * h - vec31.zCoord * i; + ex = ex * ex + f * f + g * g; + if (Double.isNaN(d[0]) || ex < d[2] - 1.0E-9) { + d[0] = h; + d[1] = i; + d[2] = ex; + } + } + } + + Vec3 direction(); + + default Vec3 L(double d) { + double ex; + return Double.isNaN(ex = this.L().D(d)) ? null : this.d(ex); + } + + private static boolean L(double d, double e, double f) { + if (!Double.isFinite(d)) { + return false; + } + + boolean bl = !Double.isFinite(ex) || d > ex + 1.0E-9; + boolean bl1 = !Double.isFinite(f) || d < f - 1.0E-9; + return bl && bl1; + } + + default double L(double d, double e, double f) { + LinearShape linearShape1 = this; + Vec3 vec31 = linearShape1.position(); + Vec3 vec3; + return VecUtils.L(vec3 = linearShape1.direction(), d - vec31.xCoord, ex - vec31.yCoord, f - vec31.zCoord) / vec3.lengthSqr(); + } + + default boolean L(AxisAlignedBB axisAlignedBB) { + return this.L(axisAlignedBB) != null; + } + + private static double L(double d, double e) { + if (Double.isFinite(d) && Double.isFinite(ex)) { + return d < ex - 1.0E-9 ? (d + ex) * 0.5 : Double.NaN; + } else if (Double.isFinite(d)) { + return d + 1.0; + } else { + return Double.isFinite(ex) ? ex - 1.0 : 0.0; + } + } + + default PointPair L(LinearShape linearShape1) { + LinearShape linearShape2 = this; + Vec3 vec31 = linearShape2.direction(); + Vec3 vec3 = linearShape1.direction(); + LineKind lineKind1 = linearShape2.L(); + LineKind lineKind = linearShape1.L(); + double d = linearShape2.position().xCoord - linearShape1.position().xCoord; + double ex = linearShape2.position().yCoord - linearShape1.position().yCoord; + double f = linearShape2.position().zCoord - linearShape1.position().zCoord; + double g = vec31.dotProduct(vec31); + double h = vec31.dotProduct(vec3); + double i = vec3.dotProduct(vec3); + double j = VecUtils.L(vec31, d, ex, f); + double k = VecUtils.L(vec3, d, ex, f); + double l = g * i - h * h; + double[] s = new double[3]; + boolean bl = true; + s[0] = Double.NaN; + s[1] = Double.NaN; + s[2] = Double.POSITIVE_INFINITY; + double[] m = s; + if (Math.abs(l) > 1.0E-9) { + L(m, lineKind1, lineKind, vec31, vec3, d, ex, f, (h * k - i * j) / l, (g * k - h * j) / l); + } + + double[] n; + int o = (n = lineKind1.L()).length; + + int p; + for (int q = p = 0; q < o; q = p) { + l = n[p]; + double u = h * l + k; + p++; + L(m, lineKind1, lineKind, vec31, vec3, d, ex, f, l, lineKind.d(u / i)); + } + + o = (n = lineKind.L()).length; + + for (int r = p = 0; r < o; r = p) { + l = n[p]; + double t = (h * l - j) / g; + p++; + L(m, lineKind1, lineKind, vec31, vec3, d, ex, f, lineKind1.d(t), l); + } + + L(m, lineKind1, lineKind, vec31, vec3, d, ex, f, lineKind1.d(-j / g), 0.0); + L(m, lineKind1, lineKind, vec31, vec3, d, ex, f, 0.0, lineKind.d(k / i)); + return Double.isNaN(m[0]) ? null : new PointPair(linearShape2.d(m[0]), linearShape1.d(m[1])); + } + + static boolean L(double d, double e) { + return Math.abs(ex - d) < 1.0E-5; + } + + default double L(Vec3 vec3) { + return this.L(vec3.xCoord, vec3.yCoord, vec3.zCoord); + } + + private static void L(AxisAlignedBB axisAlignedBB, LineKind lineKind, double d, double e, Vec3 vec3, Vec3 vec31, DoubleConsumer doubleConsumer) { + AxisAlignedBB axisAlignedBB1 = axisAlignedBB; + d = Math.max(d, lineKind.L()); + ex = Math.min(ex, lineKind.d()); + double f; + if (!Double.isNaN(f = L(d, ex))) { + Vec3 vec32 = VecUtils.L(vec3, f, vec31); + double g = 0.0; + double h = 0.0; + Axis[] axis; + int i = (axis = Axis.values()).length; + + int j; + for (int o = j = 0; o < i; o = ++j) { + Axis axis1 = axis[j]; + double k = vec32.get(axis1); + double l = vec31.get(axis1); + double m = vec3.get(axis1); + if (k < axisAlignedBB1.min(axis1)) { + g += l * l; + h += l * (m - axisAlignedBB1.min(axis1)); + } else if (k > axisAlignedBB1.max(axis1)) { + g += l * l; + h += l * (m - axisAlignedBB1.max(axis1)); + } + } + + if (Math.abs(g) <= 1.0E-9) { + doubleConsumer.accept(f); + } else { + double n; + if (L(n = -h / g, d, ex)) { + doubleConsumer.accept(n); + } + } + } + } +}