mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-31 22:25:30 +00:00
9516e94c70
--HG-- rename : mobile/android/base/FloatUtils.java => mobile/android/base/util/FloatUtils.java
30 lines
1.0 KiB
Java
30 lines
1.0 KiB
Java
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
package org.mozilla.gecko.util;
|
|
|
|
import android.graphics.PointF;
|
|
|
|
public final class FloatUtils {
|
|
private FloatUtils() {}
|
|
|
|
public static boolean fuzzyEquals(float a, float b) {
|
|
return (Math.abs(a - b) < 1e-6);
|
|
}
|
|
|
|
public static boolean fuzzyEquals(PointF a, PointF b) {
|
|
return fuzzyEquals(a.x, b.x) && fuzzyEquals(a.y, b.y);
|
|
}
|
|
|
|
/*
|
|
* Returns the value that represents a linear transition between `from` and `to` at time `t`,
|
|
* which is on the scale [0, 1). Thus with t = 0.0f, this returns `from`; with t = 1.0f, this
|
|
* returns `to`; with t = 0.5f, this returns the value halfway from `from` to `to`.
|
|
*/
|
|
public static float interpolate(float from, float to, float t) {
|
|
return from + (to - from) * t;
|
|
}
|
|
}
|