public class MathUtil
extends java.lang.Object
Constructor | Description |
---|---|
MathUtil() |
Modifier and Type | Method | Description |
---|---|---|
static double |
average(double x1,
double x2) |
Computes the average of two numbers.
|
static double |
clamp(double x,
double min,
double max) |
Clamps a double value to a given range.
|
static int |
clamp(int x,
int min,
int max) |
Clamps an int value to a given range.
|
static double |
log10(double x) |
Computes the base-10 logarithm of a double value.
|
static double |
max(double v1,
double v2,
double v3) |
|
static double |
max(double v1,
double v2,
double v3,
double v4) |
|
static double |
min(double v1,
double v2,
double v3,
double v4) |
|
static int |
wrap(int index,
int max) |
Computes an index which wraps around a given maximum value.
|
public static double clamp(double x, double min, double max)
x
- the value to clampmin
- the minimum value of the rangemax
- the maximum value of the rangepublic static int clamp(int x, int min, int max)
x
- the value to clampmin
- the minimum value of the rangemax
- the maximum value of the rangepublic static double log10(double x)
x
- a positive numberpublic static int wrap(int index, int max)
index
- the value to wrapmax
- the maximum value (or modulus)public static double average(double x1, double x2)
x1
- a numberx2
- a numberpublic static double max(double v1, double v2, double v3)
public static double max(double v1, double v2, double v3, double v4)
public static double min(double v1, double v2, double v3, double v4)
Copyright © 2018. All rights reserved.