jimu-decompiled/sources/com/google/common/math/LinearTransformation.java
2025-05-13 19:24:51 +02:00

79 lines
2.2 KiB
Java

package com.google.common.math;
import com.google.common.base.Preconditions;
/* loaded from: classes.dex */
public abstract class LinearTransformation {
public static final class LinearTransformationBuilder {
private final double a;
private final double b;
public LinearTransformation a(double d) {
Preconditions.a(!Double.isNaN(d));
return DoubleUtils.c(d) ? new RegularLinearTransformation(d, this.b - (this.a * d)) : new VerticalLinearTransformation(this.a);
}
private LinearTransformationBuilder(double d, double d2) {
this.a = d;
this.b = d2;
}
}
private static final class NaNLinearTransformation extends LinearTransformation {
static final NaNLinearTransformation a = new NaNLinearTransformation();
private NaNLinearTransformation() {
}
public String toString() {
return "NaN";
}
}
private static final class RegularLinearTransformation extends LinearTransformation {
final double a;
final double b;
RegularLinearTransformation(double d, double d2) {
this.a = d;
this.b = d2;
}
public String toString() {
return String.format("y = %g * x + %g", Double.valueOf(this.a), Double.valueOf(this.b));
}
}
private static final class VerticalLinearTransformation extends LinearTransformation {
final double a;
VerticalLinearTransformation(double d) {
this.a = d;
}
public String toString() {
return String.format("x = %g", Double.valueOf(this.a));
}
}
public static LinearTransformationBuilder a(double d, double d2) {
Preconditions.a(DoubleUtils.c(d) && DoubleUtils.c(d2));
return new LinearTransformationBuilder(d, d2);
}
public static LinearTransformation b(double d) {
Preconditions.a(DoubleUtils.c(d));
return new VerticalLinearTransformation(d);
}
public static LinearTransformation a(double d) {
Preconditions.a(DoubleUtils.c(d));
return new RegularLinearTransformation(0.0d, d);
}
public static LinearTransformation a() {
return NaNLinearTransformation.a;
}
}