92 lines
3.3 KiB
Java
92 lines
3.3 KiB
Java
package androidx.constraintlayout.motion.utils;
|
|
|
|
import androidx.constraintlayout.motion.widget.KeyCycleOscillator;
|
|
import androidx.constraintlayout.motion.widget.SplineSet;
|
|
public class VelocityMatrix {
|
|
private static String TAG = "VelocityMatrix";
|
|
public float mDRotate;
|
|
public float mDScaleX;
|
|
public float mDScaleY;
|
|
public float mDTranslateX;
|
|
public float mDTranslateY;
|
|
public float mRotate;
|
|
|
|
public void applyTransform(float f, float f2, int i, int i2, float[] fArr) {
|
|
float f3 = fArr[0];
|
|
float f4 = fArr[1];
|
|
float f5 = (f - 0.5f) * 2.0f;
|
|
float f6 = (f2 - 0.5f) * 2.0f;
|
|
float f7 = f3 + this.mDTranslateX;
|
|
float f8 = f4 + this.mDTranslateY;
|
|
float f9 = (this.mDScaleX * f5) + f7;
|
|
float f10 = (this.mDScaleY * f6) + f8;
|
|
float radians = (float) Math.toRadians((double) this.mRotate);
|
|
float radians2 = (float) Math.toRadians((double) this.mDRotate);
|
|
double d = (double) radians;
|
|
double sin = Math.sin(d);
|
|
double d2 = (double) (((float) i2) * f6);
|
|
double cos = Math.cos(d);
|
|
fArr[0] = (((float) ((sin * ((double) (((float) (-i)) * f5))) - (Math.cos(d) * d2))) * radians2) + f9;
|
|
fArr[1] = (radians2 * ((float) ((cos * ((double) (((float) i) * f5))) - (Math.sin(d) * d2)))) + f10;
|
|
}
|
|
|
|
public void clear() {
|
|
this.mDRotate = 0.0f;
|
|
this.mDTranslateY = 0.0f;
|
|
this.mDTranslateX = 0.0f;
|
|
this.mDScaleY = 0.0f;
|
|
this.mDScaleX = 0.0f;
|
|
}
|
|
|
|
public void setRotationVelocity(KeyCycleOscillator keyCycleOscillator, float f) {
|
|
if (keyCycleOscillator != null) {
|
|
this.mDRotate = keyCycleOscillator.getSlope(f);
|
|
}
|
|
}
|
|
|
|
public void setRotationVelocity(SplineSet splineSet, float f) {
|
|
if (splineSet != null) {
|
|
this.mDRotate = splineSet.getSlope(f);
|
|
this.mRotate = splineSet.get(f);
|
|
}
|
|
}
|
|
|
|
public void setScaleVelocity(KeyCycleOscillator keyCycleOscillator, KeyCycleOscillator keyCycleOscillator2, float f) {
|
|
if (keyCycleOscillator != null || keyCycleOscillator2 != null) {
|
|
if (keyCycleOscillator == null) {
|
|
this.mDScaleX = keyCycleOscillator.getSlope(f);
|
|
}
|
|
if (keyCycleOscillator2 == null) {
|
|
this.mDScaleY = keyCycleOscillator2.getSlope(f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setScaleVelocity(SplineSet splineSet, SplineSet splineSet2, float f) {
|
|
if (splineSet != null) {
|
|
this.mDScaleX = splineSet.getSlope(f);
|
|
}
|
|
if (splineSet2 != null) {
|
|
this.mDScaleY = splineSet2.getSlope(f);
|
|
}
|
|
}
|
|
|
|
public void setTranslationVelocity(KeyCycleOscillator keyCycleOscillator, KeyCycleOscillator keyCycleOscillator2, float f) {
|
|
if (keyCycleOscillator != null) {
|
|
this.mDTranslateX = keyCycleOscillator.getSlope(f);
|
|
}
|
|
if (keyCycleOscillator2 != null) {
|
|
this.mDTranslateY = keyCycleOscillator2.getSlope(f);
|
|
}
|
|
}
|
|
|
|
public void setTranslationVelocity(SplineSet splineSet, SplineSet splineSet2, float f) {
|
|
if (splineSet != null) {
|
|
this.mDTranslateX = splineSet.getSlope(f);
|
|
}
|
|
if (splineSet2 != null) {
|
|
this.mDTranslateY = splineSet2.getSlope(f);
|
|
}
|
|
}
|
|
}
|