Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: FXGLMath

[19:14] static extends: object

Static helper for FXGL's math utility class com.almasb.fxgl.core.math.FXGLMath. Provides fast lookup-table trig, random-number helpers, point/vector helpers, Bezier curve evaluation, Perlin/simplex noise entry points, and a uniform map(value, fromLo, fromHi, toLo, toHi) helper used throughout game code. Float-typed overloads from the Java side (sinF, cosF, randomFloat, sqrtF, etc.) are not exposed; Aussom does not have a separate float type so the double-precision forms cover the same need.

Methods

  • sin (double Radians)

    Returns sin(radians) using the lookup table.

  • cos (double Radians)

    Returns cos(radians) using the lookup table.

  • sinDeg (double Degrees)

    Returns sin(degrees).

  • cosDeg (double Degrees)

    Returns cos(degrees).

  • toDegrees (double Radians)

    Converts radians to degrees.

  • toRadians (double Degrees)

    Converts degrees to radians.

  • atan2 (double Y, double X)

    Returns atan2(y, x) in radians.

  • atan2Deg (double Y, double X)

    Returns atan2(y, x) in degrees.

  • rotate (double Px, double Py, double Vx, double Vy, double Angle)

    Rotates Point (px, py) around the Pivot (vx, vy) by Angle degrees. Returns the new point as an AussomJavaObject around a Point2D.

  • scale (double Px, double Py, double Vx, double Vy, double Factor)

    Scales Point (px, py) around the Pivot (vx, vy) by Factor.

  • scale1D (double X, double Pivot, double Factor)

    Scales a single double around a pivot by Factor.

  • setRandomSeed (int Seed)

    Replaces the shared Random with a fresh seeded instance, so subsequent random*() calls produce a deterministic sequence.

  • getRandom ()

    Returns the shared Random as an AussomJavaObject.

  • getRandomSeeded (int Seed)

    Returns a fresh Random seeded with the supplied value as an AussomJavaObject.

  • randomInt (int Start, int End)

    Random int in [Start, End] inclusive.

  • randomDouble (double Start = 0.0, double End = 1.0)

    Random double in [Start, End].

  • randomBool ()

    Random boolean.

  • randomBoolChance (double Chance)

    Random boolean with the supplied true-probability in [0, 1].

  • randomSign ()

    Returns 1 or -1 with equal probability.

  • randomPointIn (double X, double Y, double W, double H)

    Random point inside the given rectangle (in world coordinates).

  • randomPoint2D ()

    Random unit-square Point2D in [0, 1) x [0, 1).

  • randomVec2 ()

    Random unit-circle Vec2 with magnitude in [0, 1).

  • randomColor ()

    Random JavaFX Color (opaque).

  • randomColorHSB (double Saturation, double Brightness)

    Random JavaFX Color with fixed Saturation and Brightness.

  • randomFromList (list Items)

    Returns a random element of the Aussom list, or null when the list is empty.

  • sqrt (double X)

    sqrt(x).

  • map (double Value, double SrcLo, double SrcHi, double DstLo, double DstHi)

    Linearly maps Value from [SrcLo, SrcHi] into [DstLo, DstHi].

  • clamp (double A, double Low, double High)

    Clamps A to [Low, High]. Backed by the int / float overloads.

  • floor (double X)

    Integer floor of X.

  • abs (double Value)

    abs(value).

  • min (double A, double B)

    min(a, b).

  • max (double A, double B)

    max(a, b).

  • bezierQuad (double P1x, double P1y, double P2x, double P2y, double P3x, double P3y, double T)

    Quadratic Bezier between three control points. Returns the sampled Point2D AJO at parameter T in [0, 1].

  • bezierCubic (double P1x, double P1y, double P2x, double P2y, double P3x, double P3y, double P4x, double P4y, double T)

    Cubic Bezier between four control points. Returns the sampled Point2D AJO at parameter T in [0, 1].

  • noise1D (double T)

    1D Perlin noise at T.

  • getNoise1DGenerator (int Seed)

    Returns a seeded PerlinNoiseGenerator.

  • noise2D (double X, double Y)

    2D simplex noise at (X, Y).

  • noise3D (double X, double Y, double Z)

    3D simplex noise at (X, Y, Z).

  • distanceRects (double X1, double Y1, double W1, double H1, double X2, double Y2, double W2, double H2)

    Distance between two rectangles (0 when they overlap).

  • setRandom (object RandomAjo)

    Replaces the engine RNG with the supplied java.util.Random AJO. Lets the caller seed a deterministic Random instance.