Search Results for

    Show / Hide Table of Contents

    Class Random

    Random number generator service.

    Inheritance
    object
    IdentifiableObject
    DependencyObject
    AttachableObject
    Service
    Random
    Implements
    IDependencyObject
    Inherited Members
    AttachableObject.AttachableStateChanged
    AttachableObject.IsEnabled
    AttachableObject.State
    AttachableObject.IsLoaded
    AttachableObject.IsAttached
    AttachableObject.IsActivated
    AttachableObject.IsStarted
    AttachableObject.IsDestroyed
    AttachableObject.Destroy()
    DependencyObject.Dependencies
    DependencyObject.OnDependencyRemoved
    IdentifiableObject.Id
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Evergine.Framework.Services
    Assembly: Evergine.Framework.dll
    Syntax
    public sealed class Random : Service, IDependencyObject

    Constructors

    Random()

    Initializes a new instance of the Random class.

    Declaration
    public Random()
    Remarks

    The initial seed depends on the time.

    Random(int)

    Initializes a new instance of the Random class with a given seed.

    Declaration
    public Random(int seed)
    Parameters
    Type Name Description
    int seed

    The initial seed.

    Properties

    Seed

    Gets or sets a value indicating whether the Seed.

    Declaration
    public int Seed { get; set; }
    Property Value
    Type Description
    int

    Methods

    CreateStrongRandomSeed()

    Creates a Strong Random to use as seed... do not use to get as integer random generator cause is slow, use with caution.

    Declaration
    public int CreateStrongRandomSeed()
    Returns
    Type Description
    int

    A random integer to be used as seed.

    InUnitSphere()

    Generates a 3D vector inside a radius 1 sphere with uniform distribution.

    Declaration
    public Vector3 InUnitSphere()
    Returns
    Type Description
    Vector3

    A Vector3D.

    InsideUnitCircle()

    Generates a 2D vector inside an unit circle with uniform distribution.

    Declaration
    public Vector2 InsideUnitCircle()
    Returns
    Type Description
    Vector2

    A Vector2D.

    Next()

    Generates a random int over the range 0 to int.MaxValue-1.

    Declaration
    public int Next()
    Returns
    Type Description
    int

    A 32-bit signed integer greater than or equal to zero and less than MaxValue.

    Next(int)

    Generates a random int over the range 0 to upperBound-1, and not including upperBound.

    Declaration
    public int Next(int upperBound)
    Parameters
    Type Name Description
    int upperBound

    Non inclusive upper bound.

    Returns
    Type Description
    int

    A 32-bit signed integer greater than or equal to zero and less than upperBound.

    Next(int, int)

    Generates a random int over the range lowerBound to upperBound-1, and not including upperBound. upperBound must be >= lowerBound. lowerBound may be negative.

    Declaration
    public int Next(int lowerBound, int upperBound)
    Parameters
    Type Name Description
    int lowerBound

    The inclusive lower bound.

    int upperBound

    The non inclusive upper bound.

    Returns
    Type Description
    int

    A 32-bit signed integer greater than or equal to lowerBound and less than upperBound.

    NextBool()

    Generates a single random bit.

    Declaration
    public bool NextBool()
    Returns
    Type Description
    bool

    A boolean.

    Remarks

    This method's performance is improved by generating 32 bits in one operation and storing them ready for future calls.

    NextBool(float)

    Generates a single random bit with True value weight.

    Declaration
    public bool NextBool(float trueWeight)
    Parameters
    Type Name Description
    float trueWeight

    The weight of the TRUE value.

    Returns
    Type Description
    bool

    A boolean.

    NextBytes(byte[])

    Fills the provided byte array with random bytes.

    Declaration
    public void NextBytes(byte[] buffer)
    Parameters
    Type Name Description
    byte[] buffer

    An array of bytes to contain random numbers.

    NextDouble()

    Generates a random double between 0.0 and 1.0, not including 1.0.

    Declaration
    public double NextDouble()
    Returns
    Type Description
    double

    A double-precision floating point number greater than or equal to 0.0, and less than 1.0.

    NextInt()

    Generates a random int over the range 0 to int.MaxValue-1. Same as Next() method.

    Declaration
    public int NextInt()
    Returns
    Type Description
    int

    A 32-bit signed integer greater than or equal to zero and less or equal than MaxValue -1.

    NextRotation()

    Generates a single angle in radians [0-2*Pi).

    Declaration
    public float NextRotation()
    Returns
    Type Description
    float

    An angle.

    NextUInt()

    Generates a uint. Values returned are over the full range of a uint, uint.MinValue to uint.MaxValue, inclusive.

    Declaration
    public uint NextUInt()
    Returns
    Type Description
    uint

    A 32-bit signed integer greater than or equal to zero and less or equal than MaxValue.

    Remarks

    This is the fastest method for generating a single random number because the underlying random number generator algorithm generates 32 random bits that can be cast directly to a uint.

    OnUnitSphere()

    Generates a 3D vector in a radius 1 sphere surface with uniform distribution.

    Declaration
    public Vector3 OnUnitSphere()
    Returns
    Type Description
    Vector3

    A Vector3D.

    Implements

    IDependencyObject

    Extension Methods

    ReflectionHelper.GetMemberAssembly(object)
    ReflectionHelper.GetTypeName(object)
    In This Article
    Back to top
    Generated by DocFX