Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
randomnumbertable.h
Go to the documentation of this file.
1
#pragma once
2
#ifndef UTIL_RANDOMNUMBERTABLE_H
3
#define UTIL_RANDOMNUMNERTABLE_H
4
//------------------------------------------------------------------------------
15
#include "
core/types.h
"
16
17
//------------------------------------------------------------------------------
18
namespace
Util
19
{
20
class
RandomNumberTable
21
{
22
public
:
24
static
float
Rand
(
IndexT
key);
26
static
float
Rand
(
IndexT
key,
float
minVal,
float
maxVal);
27
28
private
:
29
static
const
SizeT
tableSize
= 2048;
30
static
const
float
randTable
[
tableSize
];
31
};
32
33
//------------------------------------------------------------------------------
36
inline
float
37
RandomNumberTable::Rand
(
IndexT
key)
38
{
39
return
randTable
[key %
tableSize
];
40
}
41
42
//------------------------------------------------------------------------------
45
inline
float
46
RandomNumberTable::Rand
(
IndexT
key,
float
minVal,
float
maxVal)
47
{
48
return
minVal + (
randTable
[key %
tableSize
] * (maxVal - minVal));
49
}
50
51
}
// namespace Util
52
//------------------------------------------------------------------------------
53
#endif
Util::RandomNumberTable
A table-based random-number generator.
Definition
randomnumbertable.h:21
Util::RandomNumberTable::tableSize
static const SizeT tableSize
Definition
randomnumbertable.h:29
Util::RandomNumberTable::Rand
static float Rand(IndexT key)
return a pseudo-random number between 0 and 1
Definition
randomnumbertable.h:37
Util::RandomNumberTable::randTable
static const float randTable[tableSize]
Definition
randomnumbertable.h:30
Util
A quad tree designed to return regions of free 2D space.
Definition
String.cs:6
types.h
SizeT
int SizeT
Definition
types.h:42
IndexT
int IndexT
Definition
types.h:41
code
foundation
util
randomnumbertable.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.