Math utility functions
More...
|
static float | Map (float value, float istart, float istop, float ostart, float ostop) |
| Map a value from one bound to another. More...
|
|
static float | Randf () |
| Return a random floating number between 0 and 1. More...
|
|
static int | RandRangei (int min, int max) |
| Return an int RandRange. More...
|
|
static float | SignedRandf () |
| Return a signed Randf, between -1 and 1. More...
|
|
static float | RandRangef (float min, float max) |
| Return a float RandRange. More...
|
|
static Vector2 | RandRangeVector2X (float minX, float maxX, float y) |
| Return a Vector with X in a random range. More...
|
|
static Vector2 | RandRangeVector2Y (float x, float minY, float maxY) |
| Return a Vector with Y in a random range. More...
|
|
static Vector2 | RandVector2 (Vector2 rangeX, Vector2 rangeY) |
| Return a Vector with coordinates in a random range (vector limits). More...
|
|
static Vector2 | RandVector2 (float minX, float maxX, float minY, float maxY) |
| Return a Vector with coordinates in a random range (float limits). More...
|
|
static Color | RandColor () |
| Return a random color. More...
|
|
Math utility functions
Definition at line 6 of file MathUtils.cs.
◆ Map()
static float MathUtils.Map |
( |
float |
value, |
|
|
float |
istart, |
|
|
float |
istop, |
|
|
float |
ostart, |
|
|
float |
ostop |
|
) |
| |
|
inlinestatic |
Map a value from one bound to another.
- Parameters
-
value | Value to map |
istart | Original lower bound |
istop | Original upper bound |
ostart | Target lower bound |
ostop | Target upper bound |
- Returns
- Mapped value
Definition at line 17 of file MathUtils.cs.
19 return ostart + ((ostop - ostart) * ((value - istart) / (istop - istart)));
◆ RandColor()
static Color MathUtils.RandColor |
( |
| ) |
|
|
inlinestatic |
Return a random color.
- Returns
- Random color
Definition at line 118 of file MathUtils.cs.
120 return new Color((
float)GD.RandRange(0, 1), (
float)GD.RandRange(0, 1), (
float)GD.RandRange(0, 1));
◆ Randf()
static float MathUtils.Randf |
( |
| ) |
|
|
inlinestatic |
Return a random floating number between 0 and 1.
- Returns
- Random floating number
Definition at line 26 of file MathUtils.cs.
28 return (
float)GD.RandRange(0, 1);
◆ RandRangef()
static float MathUtils.RandRangef |
( |
float |
min, |
|
|
float |
max |
|
) |
| |
|
inlinestatic |
Return a float RandRange.
- Parameters
-
min | Lower bound |
max | Upper bound |
- Returns
- Random float
Definition at line 57 of file MathUtils.cs.
59 return (
float)GD.RandRange(min, max);
◆ RandRangei()
static int MathUtils.RandRangei |
( |
int |
min, |
|
|
int |
max |
|
) |
| |
|
inlinestatic |
Return an int RandRange.
- Parameters
-
min | Lower bound |
max | Upper bound |
- Returns
- Random int
Definition at line 37 of file MathUtils.cs.
static float RandRangef(float min, float max)
Return a float RandRange.
◆ RandRangeVector2X()
static Vector2 MathUtils.RandRangeVector2X |
( |
float |
minX, |
|
|
float |
maxX, |
|
|
float |
y |
|
) |
| |
|
inlinestatic |
Return a Vector with X in a random range.
- Parameters
-
minX | X lower bound |
maxX | X upper bound |
y | Fixed Y value |
- Returns
- Random vector
Definition at line 69 of file MathUtils.cs.
◆ RandRangeVector2Y()
static Vector2 MathUtils.RandRangeVector2Y |
( |
float |
x, |
|
|
float |
minY, |
|
|
float |
maxY |
|
) |
| |
|
inlinestatic |
Return a Vector with Y in a random range.
- Parameters
-
x | Fixed X value |
minY | Y lower bound |
maxY | Y upper bound |
- Returns
- Random vector
Definition at line 81 of file MathUtils.cs.
◆ RandVector2() [1/2]
static Vector2 MathUtils.RandVector2 |
( |
float |
minX, |
|
|
float |
maxX, |
|
|
float |
minY, |
|
|
float |
maxY |
|
) |
| |
|
inlinestatic |
Return a Vector with coordinates in a random range (float limits).
- Parameters
-
minX | X lower bound |
maxX | X upper bound |
minY | Y lower bound |
maxY | Y upper bound |
- Returns
- Random vector
Definition at line 105 of file MathUtils.cs.
107 var vec = Vector2.Zero;
108 vec.x = (float)GD.RandRange(minX, maxX);
109 vec.y = (float)GD.RandRange(minY, maxY);
◆ RandVector2() [2/2]
static Vector2 MathUtils.RandVector2 |
( |
Vector2 |
rangeX, |
|
|
Vector2 |
rangeY |
|
) |
| |
|
inlinestatic |
Return a Vector with coordinates in a random range (vector limits).
- Parameters
-
rangeX | X bounds |
rangeY | Y bounds |
- Returns
- Random vector
Definition at line 92 of file MathUtils.cs.
94 return RandVector2(rangeX.x, rangeX.y, rangeY.x, rangeY.y);
static Vector2 RandVector2(Vector2 rangeX, Vector2 rangeY)
Return a Vector with coordinates in a random range (vector limits).
◆ SignedRandf()
static float MathUtils.SignedRandf |
( |
| ) |
|
|
inlinestatic |
Return a signed Randf, between -1 and 1.
- Returns
- Signed random floating number
Definition at line 46 of file MathUtils.cs.
48 return Map((
float)GD.RandRange(0, 1), 0, 1, -1, 1);
static float Map(float value, float istart, float istop, float ostart, float ostop)
Map a value from one bound to another.
The documentation for this class was generated from the following file: