• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Services

    Edit

    Mathf

    Provides a comprehensive set of mathematical functions and constants for game development, including operations like absolute value, square root, and trigonometric calculations, as well as game-specific algorithms like smooth damping and lerp.

    Properties

    PI

    double

    ServerAndClient

    Represents the mathematical constant Pi for circular and trigonometric calculations.

    Infinity

    double

    ServerAndClient

    Represents positive infinity, useful for comparisons.

    ServerAndClient

    Represents negative infinity, useful for comparisons.

    Deg2Rad

    double

    ServerAndClient

    Conversion factor for degrees to radians.

    Rad2Deg

    double

    ServerAndClient

    Conversion factor for radians to degrees.

    Epsilon

    double

    ServerAndClient

    Represents the smallest positive double greater than zero, preventing division by zero errors.

    Methods

    ServerAndClient

    Calculates and returns the absolute value of its input.

    Parameters

    value

    float

    A number to find the absolute value of

    Returns

    float

    The absolute value of the input number.

    ServerAndClient

    Returns the angle in radians whose cosine is the specified number, for trigonometric math operations.

    Parameters

    f

    float

    A number representing a cosine, where -1 ≤ f ≤ 1

    Returns

    float

    Angle in radians, within the range [0, π].

    ServerAndClient

    Compares two floating point values for approximate equality, to handle floating point arithmetic inconsistencies.

    Parameters

    a

    float

    The first number to compare

    b

    float

    The second number to compare

    Returns

    boolean

    True if the values are approximately equal, else false.

    ServerAndClient

    Returns the angle in radians whose sine is the specified number, useful for trigonometric operations.

    Parameters

    f

    float

    A number representing a sine, where -1 ≤ f ≤ 1

    Returns

    float

    Angle in radians within the range [-1/2π, 1/2π].

    ServerAndClient

    Returns the angle in radians whose tangent is the specified number, for trigonometric operations.

    Parameters

    f

    float

    A number representing a tangent

    Returns

    float

    Angle in radians within the range [-π/2, π/2].

    ServerAndClient

    Returns the angle in radians whose tan is y/x, useful in game physics calculations.

    Parameters

    y

    float

    The y-coordinate of a point

    x

    float

    The x-coordinate of a point

    Returns

    float

    Angle in radians within the range [-π, π].

    ServerAndClient

    Rounds a number up to the closest integer not less than the specified number, useful for setting upper limit values.

    Parameters

    f

    float

    The number to round up

    Returns

    float

    The smallest integer not less than f.

    ServerAndClient

    Rounds a number up to the nearest integer, returning an integer value, useful when working with discrete values.

    Parameters

    f

    float

    The number to round up

    Returns

    integer

    The smallest integer not less than f.

    ServerAndClient

    Restricts a number to be within a specified range, great for setting limits on variables or return values.

    Parameters

    value

    float

    The number to clamp

    min

    float

    The lower boundary of the range

    max

    float

    The upper boundary of the range

    Returns

    float

    The clamped number between min and max.

    ServerAndClient

    Restricts a number to be within the range [0,1], handy for ensuring proportions or percentages.

    Parameters

    value

    float

    The number to clamp

    Returns

    float

    The clamped value between 0 and 1.

    ServerAndClient

    Returns the power of two closest to a provided number, useful in texture resolutions.

    Parameters

    value

    int32

    The number to find the closest power of two for

    Returns

    int32

    The power of two closest to the input value.

    ServerAndClient

    Computes and returns the cosine of the specified angle in radians, for trigonometric operations.

    Parameters

    a

    float

    An angle, in radians

    Returns

    float

    The cosine of the angle.

    ServerAndClient

    Determines and returns the smallest difference between two angles, key to minimal rotation direction.

    Parameters

    current

    float

    The first angle, in degrees

    target

    float

    The second angle, in degrees

    Returns

    float

    The shortest angle difference, in degrees.

    Updated 27 days ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.