alexandroid/decompiled/jadx/sources/com/google/common/math/LinearTransformation.java
KaKi87 a47fad5135 📦 Add decompiled Alexa 2.2.730155.0 (jadx, apktool, Hermes strings)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-07 00:04:16 +01:00

229 lines
7.6 KiB
Java

package com.google.common.math;
import com.google.common.annotations.GwtIncompatible;
import com.google.common.annotations.J2ktIncompatible;
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.concurrent.LazyInit;
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
@J2ktIncompatible
@GwtIncompatible
/* loaded from: classes8.dex */
public abstract class LinearTransformation {
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class LinearTransformationBuilder {
private final double x1;
private final double y1;
private LinearTransformationBuilder(double d, double d2) {
this.x1 = d;
this.y1 = d2;
}
public LinearTransformation and(double d, double d2) {
Preconditions.checkArgument(DoubleUtils.isFinite(d) && DoubleUtils.isFinite(d2));
double d3 = this.x1;
double d4 = this.y1;
if (d != d3) {
return withSlope((d2 - d4) / (d - d3));
}
Preconditions.checkArgument(d2 != d4);
return new VerticalLinearTransformation(this.x1);
}
public LinearTransformation withSlope(double d) {
Preconditions.checkArgument(!Double.isNaN(d));
return DoubleUtils.isFinite(d) ? new RegularLinearTransformation(d, this.y1 - (this.x1 * d)) : new VerticalLinearTransformation(this.x1);
}
}
@Deprecated
public LinearTransformation() {
}
public static LinearTransformation forNaN() {
return NaNLinearTransformation.INSTANCE;
}
public static LinearTransformation horizontal(double d) {
Preconditions.checkArgument(DoubleUtils.isFinite(d));
return new RegularLinearTransformation(0.0d, d);
}
public static LinearTransformationBuilder mapping(double d, double d2) {
Preconditions.checkArgument(DoubleUtils.isFinite(d) && DoubleUtils.isFinite(d2));
return new LinearTransformationBuilder(d, d2);
}
public static LinearTransformation vertical(double d) {
Preconditions.checkArgument(DoubleUtils.isFinite(d));
return new VerticalLinearTransformation(d);
}
public abstract LinearTransformation inverse();
public abstract boolean isHorizontal();
public abstract boolean isVertical();
public abstract double slope();
public abstract double transform(double d);
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class VerticalLinearTransformation extends LinearTransformation {
@LazyInit
LinearTransformation inverse;
final double x;
public VerticalLinearTransformation(double d) {
this.x = d;
this.inverse = null;
}
private LinearTransformation createInverse() {
return new RegularLinearTransformation(0.0d, this.x, this);
}
@Override // com.google.common.math.LinearTransformation
public LinearTransformation inverse() {
LinearTransformation linearTransformation = this.inverse;
if (linearTransformation != null) {
return linearTransformation;
}
LinearTransformation createInverse = createInverse();
this.inverse = createInverse;
return createInverse;
}
@Override // com.google.common.math.LinearTransformation
public boolean isHorizontal() {
return false;
}
@Override // com.google.common.math.LinearTransformation
public boolean isVertical() {
return true;
}
@Override // com.google.common.math.LinearTransformation
public double slope() {
throw new IllegalStateException();
}
public String toString() {
return String.format("x = %g", Double.valueOf(this.x));
}
@Override // com.google.common.math.LinearTransformation
public double transform(double d) {
throw new IllegalStateException();
}
public VerticalLinearTransformation(double d, LinearTransformation linearTransformation) {
this.x = d;
this.inverse = linearTransformation;
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class RegularLinearTransformation extends LinearTransformation {
@LazyInit
LinearTransformation inverse;
final double slope;
final double yIntercept;
public RegularLinearTransformation(double d, double d2) {
this.slope = d;
this.yIntercept = d2;
this.inverse = null;
}
private LinearTransformation createInverse() {
double d = this.slope;
double d2 = this.yIntercept;
return d != 0.0d ? new RegularLinearTransformation(1.0d / d, (d2 * (-1.0d)) / d, this) : new VerticalLinearTransformation(d2, this);
}
@Override // com.google.common.math.LinearTransformation
public LinearTransformation inverse() {
LinearTransformation linearTransformation = this.inverse;
if (linearTransformation != null) {
return linearTransformation;
}
LinearTransformation createInverse = createInverse();
this.inverse = createInverse;
return createInverse;
}
@Override // com.google.common.math.LinearTransformation
public boolean isHorizontal() {
return this.slope == 0.0d;
}
@Override // com.google.common.math.LinearTransformation
public boolean isVertical() {
return false;
}
@Override // com.google.common.math.LinearTransformation
public double slope() {
return this.slope;
}
public String toString() {
return String.format("y = %g * x + %g", Double.valueOf(this.slope), Double.valueOf(this.yIntercept));
}
@Override // com.google.common.math.LinearTransformation
public double transform(double d) {
return (d * this.slope) + this.yIntercept;
}
public RegularLinearTransformation(double d, double d2, LinearTransformation linearTransformation) {
this.slope = d;
this.yIntercept = d2;
this.inverse = linearTransformation;
}
}
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
public static final class NaNLinearTransformation extends LinearTransformation {
static final NaNLinearTransformation INSTANCE = new NaNLinearTransformation();
private NaNLinearTransformation() {
}
@Override // com.google.common.math.LinearTransformation
public boolean isHorizontal() {
return false;
}
@Override // com.google.common.math.LinearTransformation
public boolean isVertical() {
return false;
}
@Override // com.google.common.math.LinearTransformation
public double slope() {
return Double.NaN;
}
public String toString() {
return "NaN";
}
@Override // com.google.common.math.LinearTransformation
public double transform(double d) {
return Double.NaN;
}
@Override // com.google.common.math.LinearTransformation
public LinearTransformation inverse() {
return this;
}
}
}