public class RMath
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static float |
PI
float of Math.PI ~ 3.1416.
|
static float |
TWO_PI
float of 2 * Math.PI ~ 6.2832.
|
| Modifier and Type | Method and Description |
|---|---|
static float |
abs(float val)
Returns the absolute value of the input.
|
static int |
abs(int val)
Returns the absolute value of the input.
|
static float |
constrain(float input,
float min,
float max)
Constrains a float value to the give min and max. min and max are both
included in the range.
|
static java.lang.Integer |
constrain(int input,
int min,
int max)
Constrains a float value to the give min and max. min and max are both
included in the range.
|
static float |
map(float input,
float inputStart,
float inputEnd,
float outputStart,
float outputEnd)
Maps (interpolates) the given input value, which has a known range of
inputStart and inputEnd, to another range.
|
static float |
max(char channel,
RColor... vals)
Returns the maximal color value found in the set of the input.
|
static float[] |
max(ColorSpace space,
RColor... vals)
Calculates the the maximal values of all color channels of the given
color set.
|
static float |
max(float... vals)
Returns the maximal value found in the set of the input.
|
static int |
max(int... vals)
Returns the maximal value found in the set of the input.
|
static int |
maxIndex(float... vals)
Returns the index of the maximal value found in the set of the input.
|
static int |
maxIndex(int... vals)
Returns the index of the maximal value found in the set of the input.
|
static float |
min(char channel,
RColor... vals)
Returns the minimal color value found in the set of the input.
|
static float[] |
min(ColorSpace space,
RColor... vals)
Calculates the the minimal values of all color channels of the given
color set.
|
static float |
min(float... vals)
Returns the minimal value found in the set of the input.
|
static int |
min(int... vals)
Returns the minimal value found in the set of the input.
|
static int |
minIndex(float... vals)
Returns the index of the minimal value found in the set of the input.
|
static int |
minIndex(int... vals)
Returns the index of the minimal value found in the set of the input.
|
static processing.core.PVector |
polarToCartesian(java.lang.Float a,
float r)
Converts polar coordinates (angle and radius) to Cartesian coordinates
(x, y).
|
static processing.core.PVector |
polarToCartesian(float basex,
float basey,
float a,
float r)
Converts polar coordinates (angle and radius) to Cartesian coordinates
(x, y).
|
static processing.core.PVector |
polarToCartesian(processing.core.PVector base,
float a,
float r)
Converts polar coordinates (angle and radius) to Cartesian coordinates
(x, y).
|
static float |
random(float max)
Returns a random float value with range of [0, max).
|
static float |
random(float min,
float max)
Returns a random float value with range of [min, max).
|
static int |
random(int max)
Returns a random int value with range of [0, max).
|
static int |
random(int min,
int max)
Returns a random int value with range of [min, max).
|
static float[] |
range(ColorSpace space,
RColor... vals)
Calculates the range (minimum and maximum values) of all color channels
the given color set.
|
static float[] |
range(float... vals)
Calculates the range (minimum and maximum values) of the given set.
|
static int[] |
range(int... vals)
Calculates the range (minimum and maximum values) of the given set.
|
static float[] |
range(processing.core.PVector... vals)
Calculates the range (minimum x / y and maximum x / y values) of the
given set.
|
public static final float PI
public static final float TWO_PI
public static processing.core.PVector polarToCartesian(java.lang.Float a,
float r)
a - The angle.r - The radius.public static processing.core.PVector polarToCartesian(processing.core.PVector base,
float a,
float r)
base - The base (translation vector).a - The angle.r - The radius.public static processing.core.PVector polarToCartesian(float basex,
float basey,
float a,
float r)
basex - The x coordinate of a translation vector.basey - The y coordinate of a translation vector.a - The angle.r - The radius.public static float constrain(float input,
float min,
float max)
input - The value that should be constrained to a range.min - The minimum of the range (value is included in the range). min
< max.max - The maximum of the range (value is included in the range). min
< max.public static java.lang.Integer constrain(int input,
int min,
int max)
input - The value that should be constrained to a range.min - The minimum of the range (value is included in the range). min
< max.max - The maximum of the range (value is included in the range). min
< max.public static float map(float input,
float inputStart,
float inputEnd,
float outputStart,
float outputEnd)
input - The value that should be interpolated.inputStart - The first value that describes the input range (inputStart <=
inputEnd or inputStart >= inputEnd). If inputStart = inputEnd,
outputStart will be returned.inputEnd - The second value that describes the input range (inputStart <=
inputEnd or inputStart >= inputEnd).outputStart - The first value that describes the output range (outputStart
<= outputEnd or outputStart >= outputEnd). If outputStart =
outputEnd, outputStart will be returned.outputEnd - The second value that describes the output range (outputStart
<= outputEnd or outputStart >= outputEnd). If outputStart =
outputEnd, outputStart will be returned.public static float random(float max)
max - The maximum of the range. max will be not included for 0 <
max. if max < 0, the output will have a range of [max, 0).public static float random(float min,
float max)
min - The minimum of the range. min will be included for min < max.
if max < min, the output will have a range of [max, min).max - The maximum of the range. max will be not included for min <
max. if max < min, the output will have a range of [max, min).public static int random(int max)
max - The maximum of the range. max will be not included for 0 <
max. if max < 0, the output will have a range of [max, 0).public static int random(int min,
int max)
min - The minimum of the range. min will be included for min < max.
if max < min, the output will have a range of [max, min).max - The maximum of the range. max will be not included for min <
max. if max < min, the output will have a range of [max, min).public static float abs(float val)
val - Any float value.public static int abs(int val)
val - Any int value.public static float min(float... vals)
vals - A set of float values.public static int min(int... vals)
vals - A set of int values.public static float[] min(ColorSpace space, RColor... vals)
space - The color space which defines which minimal values should be
calculated.vals - A set of colors.public static float min(char channel,
RColor... vals)
channel - The color channel. Either 'r', 'g' or 'b' when first color of
vals is a RGBColor, 'h', 's' or 'b' when first color of vals
is a HSBColor, 'x', 'y' or 'z' if first color of vals is a
XYZColor, 'l', 'a' or 'b' if first color is a LabColor, 'l',
'c' or 'h' if the first color is a LCHColor. For any color
space the parameter 't' will return the minimal transparency.vals - A set of colors. Best case: All colors are members of the same
color space and this color space correlates to the color
channel which the minimum should be calculated. Example: All
colors are RGBColor and the channel is 'r' for minimal red.
Minimal case: The first color of the set is member of the
color space which correlates to the given channel. Example:
First color of vals is a LabColor and the channel is 'l' for
minimal luminance.public static float max(float... vals)
vals - A set of float values.public static int max(int... vals)
vals - A set of int values.public static float max(char channel,
RColor... vals)
channel - The color channel. Either 'r', 'g' or 'b' when first color of
vals is a RGBColor, 'h', 's' or 'b' when first color of vals
is a HSBColor, 'x', 'y' or 'z' if first color of vals is a
XYZColor, 'l', 'a' or 'b' if first color is a LabColor, 'l',
'c' or 'h' if the first color is a LCHColor. For any color
space the parameter 't' will return the maximal transparency.vals - A set of colors. Best case: All colors are members of the same
color space and this color space correlates to the color
channel which the minimum should be calculated. Example: All
colors are RGBColor and the channel is 'r' for maximal red.
Minimal case: The first color of the set is member of the
color space which correlates to the given channel. Example:
First color of vals is a LabColor and the channel is 'l' for
maximal luminance.public static float[] max(ColorSpace space, RColor... vals)
space - The color space which defines which maximal values should be
calculated.vals - A set of colors.public static int[] range(int... vals)
vals - A set of int values.public static float[] range(float... vals)
vals - A set of float values.public static float[] range(ColorSpace space, RColor... vals)
space - The color space which defines which minimal values should be
calculated.vals - A set of colors.public static float[] range(processing.core.PVector... vals)
vals - A set of PVector values.public static int minIndex(int... vals)
vals - A set of int values.public static int minIndex(float... vals)
vals - A set of float values.public static int maxIndex(int... vals)
vals - A set of int values.public static int maxIndex(float... vals)
vals - A set of float values.