-
Notifications
You must be signed in to change notification settings - Fork 8
Math Library API
augments Averager<<$DataType>>
incorporates CommonCompoundMethods
Convenience class for calculating a numerical average.
EXAMPLE
uses Math/Averager
local avg = Averager<<Int32>>()
avg.add( 48 )
avg.add( 49 )
avg.add( 51 )
avg.add( 52 )
@trace avg.sum # 200
@trace avg.count # 4
@trace avg.average # 50.0
| Name | Type | Description |
|---|---|---|
| count | Int32 | |
| sum | $DataType |
| Signature | Return Type | Description |
|---|---|---|
| add( value:$DataType ) | ||
| average() | $DataType | |
| description() | String | |
| operator==( other:Averager<<$DataType>> ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Object>>() | Boxed<<Averager<<$DataType>>>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( axis:XYZ, angle:Degrees ) | AxisAngle | |
| create( axis:XYZ, angle:Radians ) | AxisAngle |
| Name | Type | Description |
|---|---|---|
| angle | Radians | |
| axis | XYZ |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator==( other:AxisAngle ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Object>>() | Boxed<<AxisAngle>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
Tracks the best value among all considered values.
EXAMPLE
# Find the smallest real number in a list.
uses Math/Best
local numbers = [3.1, 0.2, 5.8, -1.0, 4.0]
local best = Best<<Real>>( (a,b) => a < b )
forEach (value in numbers)
best.consider( value )
endForEach
println "Lowest: $" (best.value)
# Lowest: numbers[3] = -1.0
| Signature | Return Type | Description |
|---|---|---|
| create( better_fn:Function(Real,Real)->Logical ) | Best |
| Name | Type | Description |
|---|---|---|
| better_fn | Function(Real,Real)->Logical | |
| exists | Logical | |
| value | Real |
| Signature | Return Type | Description |
|---|---|---|
| clear() | ||
| consider( candidate_value:Real ) | Logical | Returns 'true' if a new best value is stored. |
| description() | String | |
| operator==( other:Best ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Logical>>() | Logical | |
| to<<Object>>() | Boxed<<Best>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
augments Best<<$DataType,$ScoreType>>
incorporates CommonCompoundMethods
Tracks the best (value,score) pair among all considered pairs.
EXAMPLE
# Find the index of the smallest real number in a list.
uses Math/Best
local numbers = [3.1, 0.2, 5.8, -1.0, 4.0]
local best = Best<<Int32,Real>>( (a,b) => a < b )
# The comparison function (a,b) should return true when score 'a' is better than score 'b'.
forEach (value at i in numbers)
best.consider( i, value )
endForEach
println "Lowest: numbers[$] = $" (best.value,best.score)
# Lowest: numbers[3] = -1.0
| Signature | Return Type | Description |
|---|---|---|
| create( better_fn:Function($ScoreType,$ScoreType)->Logical ) | Best<<$DataType,$ScoreType>> |
| Name | Type | Description |
|---|---|---|
| better_fn | Function($ScoreType,$ScoreType)->Logical | |
| exists | Logical | |
| score | $ScoreType | |
| value | $DataType |
| Signature | Return Type | Description |
|---|---|---|
| clear() | ||
| consider( candidate_value:$DataType, candidate_score:$ScoreType ) | Logical | Returns 'true' if a new best value is stored. |
| description() | String | |
| operator==( other:Best<<$DataType,$ScoreType>> ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Logical>>() | Logical | |
| to<<Object>>() | Boxed<<Best<<$DataType,$ScoreType>>>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
augments Best<<$DataType>>
incorporates CommonCompoundMethods
Tracks the best value among all considered values.
EXAMPLE
# Find the smallest real number in a list.
uses Math/Best
local numbers = [3.1, 0.2, 5.8, -1.0, 4.0]
local best = Best<<Real>>( (a,b) => a < b )
forEach (value in numbers)
best.consider( value )
endForEach
println "Lowest: $" (best.value)
# Lowest: numbers[3] = -1.0
| Signature | Return Type | Description |
|---|---|---|
| create( better_fn:Function($DataType,$DataType)->Logical ) | Best<<$DataType>> |
| Name | Type | Description |
|---|---|---|
| better_fn | Function($DataType,$DataType)->Logical | |
| exists | Logical | |
| value | $DataType |
| Signature | Return Type | Description |
|---|---|---|
| clear() | ||
| consider( candidate_value:$DataType ) | Logical | Returns 'true' if a new best value is stored. |
| description() | String | |
| operator==( other:Best<<$DataType>> ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Logical>>() | Logical | |
| to<<Object>>() | Boxed<<Best<<$DataType>>>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
| Name | Type | Description |
|---|---|---|
| i64_limit | BigInt | |
| one | BigInt | |
| setup_complete | Logical | |
| ten | BigInt | |
| ten_e144 | BigInt | |
| ten_e18 | BigInt | |
| ten_e36 | BigInt | |
| ten_e72 | BigInt | |
| values | BigInt[] | |
| zero | BigInt |
| Signature | Return Type | Description |
|---|---|---|
| create( n:Int32 ) | BigInt | |
| create( n:Int64 ) | BigInt | Creates a BigInt object out of an Int64 value. If 'n' is 0..15 then a pre-defined BigInt object will be returned instead. |
| init_class() |
| Name | Type | Description |
|---|---|---|
| data | Int32[] | |
| sign_flag | Int | 1 or -1 |
| Signature | Return Type | Description |
|---|---|---|
| init( other:BigInt ) | ||
| init( value:Int64, new_object:Logical ) | ||
| init( value:String, [base=10:Int32] ) | Initializes this BigInt to a value specified as a string of digits in a given base. 'base' can be 2, 10, or 16. | |
| bits() | Int32 | |
| divide_and_mod( n:BigInt ) | BigIntDivideAndModResult | |
| divide_and_mod( n:Int64 ) | BigIntDivideAndModResult | |
| format( fmt:String ) | String |
fmt - #: right-justify in this many spaces; 0 fill if begins with 0 - ,: put comma separators |
| is_negative() | Logical | |
| is_valid_int32() | Logical | |
| is_valid_int64() | Logical | |
| is_zero() | Logical | |
| normalized() | BigInt | Removes excess zero values on the most signficant end and changes a negative zero to a positive zero. |
| operator-() | BigInt | |
| operator%( n:BigInt ) | BigInt | |
| operator%( n:Int64 ) | BigInt | |
| operator&( n:BigInt ) | BigInt | |
| operator&( n:Int64 ) | BigInt | |
| operator*( n:BigInt ) | BigInt | |
| operator*( n:Int64 ) | BigInt | |
| operator+( n:BigInt ) | BigInt | |
| operator+( n:Int64 ) | BigInt | |
| operator-( n:BigInt ) | BigInt | |
| operator-( n:Int64 ) | BigInt | |
| operator/( n:BigInt ) | BigInt | |
| operator/( n:Int64 ) | BigInt | |
| operator:<<:( bits:Int32 ) | BigInt | |
| operator:>>:( bits:Int32 ) | BigInt | |
| operator:>>>:( bits:Int32 ) | BigInt | |
| operator<>( n:Int64 ) | Int | |
| operator<>( other:BigInt ) | Int | |
| operator==( n:Int64 ) | Logical | |
| operator==( other:BigInt ) | Logical | |
| operator^( n:BigInt ) | BigInt | |
| operator^( n:Int64 ) | BigInt | |
| operator|( n:BigInt ) | BigInt | |
| operator|( n:Int64 ) | BigInt | |
| operator~( n:BigInt ) | BigInt | |
| operator~( n:Int64 ) | BigInt | |
| sign() | Int32 | Returns -1, 0, or 1. |
| sqrt() | BigInt | |
| to<<Int32>>() | Int32 | |
| to<<Int64>>() | Int64 | |
| to<<String>>() | String | |
| to<<String>>( &binary, &hex ) | String | |
| to<<String>>( base:Int32 ) | String |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( division:BigInt, modulo:BigInt ) | BigIntDivideAndModResult |
| Name | Type | Description |
|---|---|---|
| division | BigInt | |
| modulo | BigInt |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator==( other:BigIntDivideAndModResult ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Object>>() | Boxed<<BigIntDivideAndModResult>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( degrees:Radians ) | Degrees | |
| create( value:Real ) | Degrees | |
| operator?( degrees:Degrees ) | Logical |
| Name | Type | Description |
|---|---|---|
| value | Real |
| Signature | Return Type | Description |
|---|---|---|
| clamped( min:Degrees, max:Degrees ) | Degrees | |
| cos() | Real | |
| delta_to( other:Degrees ) | Degrees | Returns the smallest number of degrees necessary to get from this angle to the specified other angle. For example, Degrees(270).delta_to(Degrees(0)) yields Degrees(90), since turning 90 degrees will get you to 0 degrees "faster" than turning -270 degrees. |
| description() | String | |
| floor() | Degrees | |
| hashcode() | Int | |
| operator-() | Degrees | |
| operator%( degrees:Real ) | Degrees | |
| operator%( other:Degrees ) | Degrees | |
| operator*( degrees:Real ) | Degrees | |
| operator*( other:Degrees ) | Degrees | |
| operator+( degrees:Real ) | Degrees | |
| operator+( other:Degrees ) | Degrees | |
| operator-( degrees:Real ) | Degrees | |
| operator-( other:Degrees ) | Degrees | |
| operator/( degrees:Real ) | Degrees | |
| operator/( other:Degrees ) | Degrees | |
| operator<>( other:Degrees ) | Real | |
| operator<>( other_value:Real ) | Real | |
| operator==( other:Degrees ) | Logical | |
| operator==( other_value:Real ) | Logical | |
| operator^( degrees:Real ) | Degrees | |
| operator^( other:Degrees ) | Degrees | |
| print_to( buffer:PrintWriter ) | ||
| sin() | Real | |
| tan() | Real | |
| to<<Object>>() | Boxed<<Degrees>> | |
| to<<Radians>>() | Radians | |
| to<<Real>>() | Real | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
incorporates CommonCompoundMethods
| Name | Type | Description |
|---|---|---|
| homogeneous_depth | Logical | |
| left_handed | Logical |
| Signature | Return Type | Description |
|---|---|---|
| create() | Matrix | |
| create( r0c0:Real, r1c0:Real, r2c0:Real, r3c0:Real, r0c1:Real, r1c1:Real, r2c1:Real, r3c1:Real, r0c2:Real, r1c2:Real, r2c2:Real, r3c2:Real, r0c3:Real, r1c3:Real, r2c3:Real, r3c3:Real ) | Matrix | |
| decimal_digit_count( value:Real ) | Int32 | |
| frustum( left:Real, right:Real, bottom:Real, top:Real, z_near:Real, z_far:Real, [homogeneous_depth=Matrix.homogeneous_depth:Logical], [left_handed=Matrix.left_handed:Logical] ) | Matrix | |
| identity() | Matrix | |
| look_at( origin:XYZ, target:XYZ, [up=XYZ(0,-1,0):XYZ], [left_handed=Matrix.left_handed:Logical] ) | Matrix | |
| mode_2dx( width:Real, height:Real, [depth_scale=1.0:Real], [nominal_z=null:Real?], [perspective_center=XY(0.5,0.5):XY], [invert_y=false:Logical], [homogeneous_depth=Matrix.homogeneous_depth:Logical], [left_handed=Matrix.left_handed:Logical] ) | Matrix | |
| orthographic( left:Real, right:Real, bottom:Real, top:Real, near:Real, far:Real, [offset=0.0:Real], [homogeneous_depth=Matrix.homogeneous_depth:Logical], [left_handed=Matrix.left_handed:Logical] ) | Matrix | |
| perspective( fov_y:Radians, aspect_ratio:Real, z_near:Real, z_far:Real, [homogeneous_depth=Matrix.homogeneous_depth:Logical], [left_handed=Matrix.left_handed:Logical] ) | Matrix | |
| rotate( degrees:DegreesXYZ ) | Matrix | |
| rotate( radians:RadiansXYZ ) | Matrix | |
| rotate( theta:Radians, axis:XYZ ) | Matrix | |
| rotate_x( theta:Radians ) | Matrix | |
| rotate_xy( radians:RadiansXY ) | Matrix | |
| rotate_xyz( radians:RadiansXYZ ) | ||
| rotate_y( theta:Radians ) | Matrix | |
| rotate_z( theta:Radians ) | Matrix | |
| rotate_zyx( radians:RadiansXYZ ) | ||
| scale( k:Real ) | Matrix | |
| scale( k:Real, origin:XY ) | Matrix | |
| scale( k:XY ) | Matrix | |
| scale( k:XY, origin:XY ) | Matrix | |
| scale( k:XYZ ) | Matrix | |
| scale( k:XYZ, origin:XYZ ) | Matrix | |
| shear( x_yz:XY, y_xz:XY, z_xy:XY ) | Matrix | x_yz: amount that x is sheared proportional to changes in y and z y_xz: amount that y is sheared proportional to changes in x and z z_xy: amount that z is sheared proportional to changes in x and y |
| shear( xy:XY ) | Matrix | |
| transform( position:XYZ, anchor:Anchor, size:XY, internal_size:XY, scale_z:Real, [h_flip=false:Logical], [v_flip=false:Logical] ) | Matrix |
Returns a matrix encoding the following transformations in order of effect: translate( (XY(0.5,0.5)-anchor.position) * internal_size ) # Put the anchor at (0,0) scale( size / internal_size ) if (h_flip) scale_x( -1 ) if (v_flip) scale_y( -1 ) translate( position ) |
| transform( position:XYZ, anchor:Anchor, size:XY, internal_size:XY, scale_z:Real, rotation:Quaternion, [h_flip=false:Logical], [v_flip=false:Logical] ) | Matrix |
Returns a matrix encoding the following transformations in order of effect: translate( -anchor.position * internal_size ) # Put anchor at origin scale( size / internal_size ) if (h_flip) scale_x( -1 ) if (v_flip) scale_y( -1 ) rotate( rotation ) # 3D rotation translate( position ) |
| transform( position:XYZ, anchor:Anchor, size:XY, internal_size:XY, scale_z:Real, rotation:Radians, [h_flip=false:Logical], [v_flip=false:Logical] ) | Matrix |
Returns a matrix encoding the following transformations in order of effect: translate( (XY(0.5,0.5)-anchor.position) * internal_size ) # Put the anchor at (0,0) scale( size / internal_size ) if (h_flip) scale_x( -1 ) if (v_flip) scale_y( -1 ) rotate_z( rotation ) # 2D rotation translate( position ) |
| translate( delta:XY ) | Matrix | |
| translate( delta:XYZ ) | Matrix | |
| viewport( left:Real, top:Real, width:Real, height:Real ) | Matrix | Returns a matrix that converts coordinates from (left..<left+width)x(top..<top+height) -> (-1..1,-1..1) |
| whole_digit_count( value:Real ) | Int32 |
| Name | Type | Description |
|---|---|---|
| r0c0 | Real | |
| r0c1 | Real | |
| r0c2 | Real | |
| r0c3 | Real | |
| r1c0 | Real | |
| r1c1 | Real | |
| r1c2 | Real | |
| r1c3 | Real | |
| r2c0 | Real | |
| r2c1 | Real | |
| r2c2 | Real | |
| r2c3 | Real | |
| r3c0 | Real | |
| r3c1 | Real | |
| r3c2 | Real | |
| r3c3 | Real |
| Signature | Return Type | Description |
|---|---|---|
| count() | Int32 | |
| description() | String | |
| get( index:Int32 ) | Real | |
| inverse_transpose() | Matrix | |
| inverted() | Matrix | |
| operator*( other:Matrix ) | Matrix | |
| operator*( v:XY ) | XYZW | |
| operator*( v:XYZ ) | XYZW | |
| operator*( v:XYZW ) | XYZW | |
| operator==( other:Matrix ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| set( index:Int32, value:Real ) | ||
| to<<Matrix32>>() | Matrix32 | |
| to<<Object>>() | Boxed<<Matrix>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| transposed() | Matrix | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( r0c0:Real32, r1c0:Real32, r2c0:Real32, r3c0:Real32, r0c1:Real32, r1c1:Real32, r2c1:Real32, r3c1:Real32, r0c2:Real32, r1c2:Real32, r2c2:Real32, r3c2:Real32, r0c3:Real32, r1c3:Real32, r2c3:Real32, r3c3:Real32 ) | Matrix32 |
| Name | Type | Description |
|---|---|---|
| r0c0 | Real32 | |
| r0c1 | Real32 | |
| r0c2 | Real32 | |
| r0c3 | Real32 | |
| r1c0 | Real32 | |
| r1c1 | Real32 | |
| r1c2 | Real32 | |
| r1c3 | Real32 | |
| r2c0 | Real32 | |
| r2c1 | Real32 | |
| r2c2 | Real32 | |
| r2c3 | Real32 | |
| r3c0 | Real32 | |
| r3c1 | Real32 | |
| r3c2 | Real32 | |
| r3c3 | Real32 |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| operator==( other:Matrix32 ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| to<<Matrix>>() | Matrix | |
| to<<Object>>() | Boxed<<Matrix32>> | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
| Name | Type | Description |
|---|---|---|
| default_permutation_values | Byte[] |
| Name | Type | Description |
|---|---|---|
| permutation_table | Int[] |
| Signature | Return Type | Description |
|---|---|---|
| init() | ||
| generate( width:Int, height:Int, [frequency=8.0:Real], [output=Real[]:Real[]] ) | Real[] |
Generates a width×height list of 2D Perlin noise values, each -1..1. frequency How “zoomed” the noise is; increase for larger features. |
| randomize( [random=Random:Random] ) | ||
| use_default_settings() |
incorporates CommonCompoundMethods
Adapted from the Iirlicht Quaternion by Nikolaus Gebhardt
| Signature | Return Type | Description |
|---|---|---|
| create( [x=0:Real], [y=0:Real], [z=0:Real], [w=1.0:Real] ) | Quaternion | |
| create( aa:AxisAngle ) | Quaternion | |
| create( from:XYZ, to:XYZ ) | Quaternion | |
| create( m:Matrix ) | Quaternion | |
| create( rotation:RadiansXYZ ) | Quaternion | |
| identity() | Quaternion |
| Name | Type | Description |
|---|---|---|
| w | Real | |
| x | Real | |
| y | Real | |
| z | Real |
| Signature | Return Type | Description |
|---|---|---|
| description() | String | |
| dot( other:Quaternion ) | Real | |
| inverted() | Quaternion | |
| is_identity() | Logical | |
| linear_tween( target:Quaternion, t:Real ) | Quaternion | |
| matches( other:Quaternion, tolerance:Real ) | Logical | |
| normalized() | Quaternion | |
| operator*( n:Real ) | Quaternion | |
| operator*( other:Quaternion ) | Quaternion | |
| operator*( v:XYZ ) | XYZ | |
| operator+( other:Quaternion ) | Quaternion | |
| operator/( n:Real ) | Quaternion | |
| operator==( other:Quaternion ) | Logical | |
| print_to( buffer:PrintWriter ) | ||
| rotated( by_angles:RadiansXYZ ) | Quaternion | |
| to<<AxisAngle>>() | AxisAngle | |
| to<<Matrix>>() | Matrix | |
| to<<Object>>() | Boxed<<Quaternion>> | |
| to<<RadiansXYZ>>() | RadiansXYZ | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| to<<Matrix>>( handle:XYZ, translate:XYZ ) | Matrix | |
| tween( target:Quaternion, t:Real, [threshold=0.05:Real] ) | Quaternion | |
| type_info() | TypeInfo |
incorporates CommonCompoundMethods
| Signature | Return Type | Description |
|---|---|---|
| create( degrees:Degrees ) | Radians | |
| create( value:Real ) | Radians | |
| operator?( radians:Radians ) | Logical |
| Name | Type | Description |
|---|---|---|
| value | Real |
| Signature | Return Type | Description |
|---|---|---|
| clamped( min:Radians, max:Radians ) | Radians | |
| cos() | Real | |
| delta_to( other:Radians ) | Radians | Returns the smallest number of radians necessary to get from this angle to the specified other angle. For example, Radians(pi*3/2).delta_to(Radians(0)) yields Radians(pi/2), since turning pi/2 radians will get you to 0 radians "faster" than turning -pi*3/2 radians. |
| description() | String | |
| hashcode() | Int | |
| operator-() | Radians | |
| operator%( other:Radians ) | Radians | |
| operator%( radians:Real ) | Radians | |
| operator*( other:Radians ) | Radians | |
| operator*( radians:Real ) | Radians | |
| operator+( other:Radians ) | Radians | |
| operator+( radians:Real ) | Radians | |
| operator-( other:Radians ) | Radians | |
| operator-( radians:Real ) | Radians | |
| operator/( other:Radians ) | Radians | |
| operator/( radians:Real ) | Radians | |
| operator<>( other:Degrees ) | Real | |
| operator<>( other_value:Real ) | Real | |
| operator==( other:Degrees ) | Logical | |
| operator==( other:Radians ) | Logical | |
| operator==( other_value:Real ) | Logical | |
| operator^( other:Radians ) | Radians | |
| operator^( radians:Real ) | Radians | |
| print_to( buffer:PrintWriter ) | ||
| sin() | Real | |
| tan() | Real | |
| to<<Degrees>>() | Degrees | |
| to<<Object>>() | Boxed<<Radians>> | |
| to<<Real>>() | Real | |
| to<<String>>() | String | |
| to<<Variant>>() | Variant | |
| type_info() | TypeInfo |
extends Object
This random number generator produces evenly distributed pseudo-random values.
You may create a Random object with a 'seed' value; generators created with the same seed always return the same sequence of random numbers. If a seed is not specified then the current System.time_ms is used.
Under the hood Random uses the PCG32 algorithm adapted from:
https://github.com/imneme/pcg-c-basic
JS equivalent: - https://www.npmjs.com/package/pcg-random - new PcgRandom(seed,0).integer() & 0x7FFFFFFF <> Random(seed).int32
| Name | Type | Description |
|---|---|---|
| seed | Int64 | The original state value. |
| state | Int64 | The current state used to produce the next psuedo-random number. |
| stream | Int64 | A PCG32-specific modifier that essentially acts as an additional seed. |
| Signature | Return Type | Description |
|---|---|---|
| init() | ||
| init( existing:Random ) | Constructs this Random generator to be a duplicate of an existing Random generator. They will produce identical results given identical calls. | |
| init( seed:Int64, [stream=0x14057b7ef767814f:Int64] ) | Constructs a Random generator with the specified seed and optional stream parameter. 'stream' defaults to 0x14057b7e_f767814f. If you pass an explicit value, note that the canonical PCG algorithm performs 'stream = (stream :<<: 1) | 1' but this implementation only performs 'stream | 1'. This ensures that 'stream' isn't modified each time it is passed from one Random generator to another. | |
| byte() | Byte | Returns a random byte between 0 and 255. |
| chance( p:Real ) | Logical |
Has a proportional chance 'p' to return true (0 < p < 1.0). Example: Random.chance(0.75) # returns true 75% of the time statistically speaking. |
| cloned() | Random | Returns a duplicate Random generator. Given identical calls, it will produce identical results to this Random generator. |
| color() | Color | Returns a color with randomized (r,g,b) values and an alpha of 1.0. |
| degrees() | Degrees | |
| gaussian() | Real | Returns a random number from a normal distribution of avg=0, stddev=1 68.2% chance of being between -1..1 95.45% chance of being between -2..2 99.73% chance of being -3..3 99.994% chance of being -4..4 Real number precision limits the results to [-8.5,8.5] From: https://stackoverflow.com/a/218600/135791 |
| hashcode() | Int | |
| int() | Int | |
| int32() | Int32 | Returns a normalized, evenly distributed random integer in the range [0,2^31-1] inclusive. |
| int64() | Int64 | Returns a normalized, evenly distributed random integer in the range [0,2^63-1] inclusive. |
| int( limit:Int ) | Int |
Returns an evenly distributed random integer in the range [0,limit) - includes 0 but does not include limit. int(limit) is preferred over int % limit because it avoids the low number bias of a simple lib. Example: println( Random.int(100) ) # Prints a number 0..99 |
| int( low:Int, high:Int ) | Int | Returns a random integer between low and high, inclusive. |
| int32( limit:Int32 ) | Int32 |
Returns an evenly distributed random integer in the range [0,limit) - includes 0 but does not include limit. int32(limit) is preferred over int32 % limit because it avoids the low number bias of a simple lib. Example: println( Random.int32(100) ) # Prints a number 0..99 |
| int32( low:Int32, high:Int32 ) | Int32 | Returns a random integer between low and high, inclusive. |
| int_xy( limit:Int ) | IntXY | |
| int_xy( limit:IntXY ) | IntXY | |
| logical() | Logical | Returns either "true" or "false" with equal likelihood. |
| next32() | Int32 | Returns an pseudo-random Int32 in the full range of possible values [-80000000,7FFFffff]. |
| radians() | Radians | |
| real() | Real | Returns a random number 0 < n < 1.0 |
| real32() | Real32 | Returns a random number 0 < n < 1.0 |
| real64() | Real64 | Returns a random number 0 < n < 1.0 |
| real( limit:Real ) | Real | Returns a random number 0 < n < limit |
| real( low:Real, high:Real ) | Real | Returns a random number low < n < high |
| real32( limit:Real32 ) | Real32 | Returns a random number 0 < n < limit |
| real32( low:Real32, high:Real32 ) | Real32 | Returns a random number low < n < high |
| real64( limit:Real64 ) | Real64 | Returns a random number 0 < n < limit |
| real64( low:Real64, high:Real64 ) | Real64 | Returns a random number low < n < high |
| reset( seed:Int64, [stream=0x14057b7ef767814f:Int64] ) | Resets the Random generator to use the specified seed and optional stream parameter. 'stream' defaults to 0x14057b7e_f767814f. If you pass an explicit value, note that the canonical PCG algorithm performs 'stream = (stream :<<: 1) | 1' but this implementation only performs 'stream | 1'. This ensures that 'stream' isn't modified each time it is passed from one Random generator to another. | |
| string( n:Int, [characters=null:String] ) | String | |
| xy() | XY | |
| xy( limit:Real ) | XY | |
| xy( limit:XY ) | XY | |
| xyz() | XYZ | Creates a XYZ compound with randomized (x,y,z) values, each in the range (0.0,1.0) exclusive. |
| xyz( low:Real, high:Real ) | XYZ | Returns a XYZ compound with an evenly distributed random real number in the range (low,high) exclusive (does not include low or high). for each of the (x,y,z) values. |
| xyzw() | XYZW | Creates a XYZW compound with randomized (x,y,z,w) values, each in the range (0.0,1.0) exclusive. |
| xyzw( low:Real, high:Real ) | XYZW | Returns a XYZW compound with an evenly distributed random real number in the range (low,high) exclusive (does not include low or high). for each of the (x,y,z,w) values. |