PiMath API
    Preparing search index...

    Variable RandomConst

    Random: {
        array: <T>(arr: T[], number?: number) => T[];
        bool: (percent?: number) => boolean;
        circle: (config?: RandomGeometryCircleConfig) => Circle;
        equation: (config?: RandomEquationConfig) => Equation;
        fraction: (config?: RandomCoefficientConfig) => Fraction;
        item: <T>(arr: T[]) => T;
        line: (config?: RandomGeometryLineConfig) => Line;
        line3: (config?: RandomGeometryLine3Config) => Line3;
        monom: (config?: RandomMonomConfig) => Monom;
        number: (from: number, to: number, exclude?: number[]) => number;
        numberSym: (max: number, allowZero?: boolean) => number;
        point: (config?: RandomGeometryPointConfig) => Point;
        point3: (config?: RandomGeometryPoint3Config) => Point;
        polynom: (config?: RandomPolynomConfig) => Polynom;
        prime: (max?: number) => number;
        shuffle: <T>(arr: T[]) => T[];
        triplet: (
            target: number,
            allowZero?: boolean,
        ) => [number, number, number] | null;
        vector: (config?: RandomGeometryVectorConfig) => Vector;
        vector3: (config?: RandomGeometryVector3Config) => Vector;
    } = ...

    Facade of the random generators and helpers. Each generator takes an optional configuration, described by its Random***Config type and by the rnd*** function it forwards to; the helpers (number, bool, item…) document their arguments below.

    Type Declaration

    • array: <T>(arr: T[], number?: number) => T[]

      Up to number distinct elements of arr (default 1), in random order; arr is not modified.

    • bool: (percent?: number) => boolean

      true with the probability percent (between 0 and 1, default 0.5).

    • circle: (config?: RandomGeometryCircleConfig) => Circle

      Random circle, from a center and a radius, optionally with integer points on it.

    • equation: (config?: RandomEquationConfig) => Equation

      Random equation or inequality, with controlled solutions (solution.count, nothing, everything).

    • fraction: (config?: RandomCoefficientConfig) => Fraction

      Random fraction or integer, with its sign, range and size under control.

    • item: <T>(arr: T[]) => T

      Random element of arr.

      if arr is empty.

    • line: (config?: RandomGeometryLineConfig) => Line

      Random line of the plane, from a point and a slope, with a chosen kind (vertical, horizontal, positive, negative).

    • line3: (config?: RandomGeometryLine3Config) => Line3

      Random line of space, from a point and a direction, with a chosen kind (general or parallel to a plane or an axis).

    • monom: (config?: RandomMonomConfig) => Monom

      Random term such as 3x² or -½xy.

    • number: (from: number, to: number, exclude?: number[]) => number

      Random integer in [from, to], both bounds included (swapped if from > to), never one of exclude.

      if exclude removes every value of the interval.

    • numberSym: (max: number, allowZero?: boolean) => number

      Random integer in [-max, max]; allowZero: false excludes 0.

    • point: (config?: RandomGeometryPointConfig) => Point

      Random point of the plane, constrained by axis, quadrant and range.

    • point3: (config?: RandomGeometryPoint3Config) => Point

      Random point of space, constrained by axis, plane, octant and range.

    • polynom: (config?: RandomPolynomConfig) => Polynom

      Random polynomial of a given degree, possibly factorable into linear factors.

    • prime: (max?: number) => number

      Random prime strictly lower than max (any prime of the list when max is omitted).

    • shuffle: <T>(arr: T[]) => T[]

      Shuffled copy of arr; arr is not modified.

    • triplet: (target: number, allowZero?: boolean) => [number, number, number] | null

      Random Pythagorean triplet whose hypotenuse is target, or null when there is none. Triplets that contain 0 are left out unless allowZero is true.

    • vector: (config?: RandomGeometryVectorConfig) => Vector

      Random vector of the plane, drawn like a point; the zero vector is excluded by default.

    • vector3: (config?: RandomGeometryVector3Config) => Vector

      Random vector of space, drawn like a point; the zero vector is excluded by default.