|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object common:Generic common:Generator dmj5:DMJ_GeneratorRandom
class
This Generator produces a random sequence. The random number generator is very simple and quick.
class DMJ_GeneratorRandom(common.ulb:Generator) { ; This Generator produces a random sequence. The random number generator is very simple and quick. public: import "common.ulb" ; Constructor ; @param pparent = a reference to the object creating the new object; typically, 'this' func DMJ_GeneratorRandom(Generic pparent) Generator.Generator(pparent) endfunc ; Set up for a sequence of values ; ; This function will be called at the beginning of each ; sequence of values (e.g. at the beginning of each fractal ; orbit). ; @param pz = seed value for the sequence ; @return first value in the sequence float func Init(float pz) Generator.Init(pz) ; Base class implementation flags the sequence to end ; immediately. We don't want this (this sequence proceeds ; indefinitely) so clear the flag. m_BailedOut = false return pz endfunc ; Set up for a sequence of values ; ; This alternate form of Init will cause the Generator to ; start with its "default" sequence. This can be used if a ; generator allows a user to select a "seed" value itself. ; Such Generator classes should override this function. ; @return first value in the sequence float func InitDefault() return Init(@p_seed / 2147483648.0) endfunc ; Produce the next value in the sequence ; float func Iterate(float pz) Generator.Iterate(pz) pz = pz * 2147483648.0 pz = (pz * 1103515245 + 12345) % 2147483648.0 pz = pz / 2147483648.0 return pz endfunc protected: default: title = "Random" int param v_dmj_generatorrandom caption = "Version (DMJ_GeneratorRandom)" default = 100 hint = "This version parameter is used to detect when a change has been made to the formula that is incompatible with the previous version. When that happens, this field will reflect the old version number to alert you to the fact that an alternate rendering is being used." visible = @v_dmj_generatorrandom < 100 endparam int param p_seed caption = "Seed" default = 51853571 hint = "Sets the seed for the random number generator. Each different seed produces a different sequence of random values." endparam }
Constructor Summary | |
---|---|
DMJ_GeneratorRandom()
|
|
DMJ_GeneratorRandom(Generic pparent)
Constructor |
Method Summary | |
---|---|
float |
Init(float pz)
Set up for a sequence of values This function will be called at the beginning of each sequence of values (e.g. |
float |
InitDefault()
Set up for a sequence of values This alternate form of Init will cause the Generator to start with its "default" sequence. |
float |
Iterate(float pz)
Produce the next value in the sequence |
Methods inherited from class common:Generator |
---|
IsBailedOut |
Methods inherited from class common:Generic |
---|
GetParent |
Methods inherited from class Object |
---|
|
Constructor Detail |
---|
public DMJ_GeneratorRandom(Generic pparent)
pparent
- = a reference to the object creating the new object; typically, 'this'public DMJ_GeneratorRandom()
Method Detail |
---|
public float Init(float pz)
Init
in class Generator
pz
- = seed value for the sequence
public float InitDefault()
InitDefault
in class Generator
public float Iterate(float pz)
Iterate
in class Generator
pz
- previous value in the sequence. Note that you should always use this value for computing the next iteration, rather than a saved value, as the calling code may modify the returned value before passing it back to the next Iterate() call.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |