• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • API

    Datatypes

    Edit

    Vector4

    Represents a vector or a point in four-dimensional space, commonly used for RGBA values, 4D transforms, or 3D transformations with homogeneous coordinates.

    Properties

    Provides a normalized version of the Vector4, with a length of 1, useful for direction-only applications.

    magnitude

    number

    Provides the length of the Vector4, useful for distance calculations or scaling vectors.

    Returns the square of the magnitude of the Vector4, a performance-friendly alternative for length comparisons.

    x

    number

    Accesses the 'x' component of the Vector4, representing different dimensions or the 'Red' component in RGBA.

    y

    number

    Accesses the 'y' component of the Vector4, representing different dimensions or the 'Green' component in RGBA.

    z

    number

    Accesses the 'z' component of the Vector4, representing different dimensions or the 'Blue' component in RGBA.

    w

    number

    Accesses the 'w' component of the Vector4, representing different dimensions or the 'Alpha' component in RGBA.

    Represents a Vector4 with all components set to zero.

    Represents a Vector4 with all components set to one, useful for certain mathematical operations.

    Represents a Vector4 with all components set to positive infinity, useful for setting maximum limits.

    Represents a Vector4 with all components set to negative infinity, useful for setting minimum limits.

    kEpsilon

    number

    Represents a tiny positive number close to zero, used to handle calculations related to precision.

    Methods

    Sets the 'x', 'y', 'z', and 'w' components of the Vector4, enhancing code readability and efficiency.

    Parameters

    newX

    number

    The new 'x' component.

    newY

    number

    The new 'y' component.

    newZ

    number

    The new 'z' component.

    newW

    number

    The new 'w' component.

    Returns

    void

    Scales a Vector4 by another Vector4's components, useful for dimension or shape scaling.

    Parameters

    scale
    Vector4

    The Vector4 to scale by.

    Returns

    void

    Transforms the Vector4 into a vector of same direction but with length 1, ideal for direction-only uses.

    Returns

    void

    Provides the square of the magnitude of the Vector4, an efficient method for length comparisons.

    Returns

    number

    Returns the square of the magnitude.

    Performs Linear Interpolation between two Vector4's based on a parameter 't', useful for smooth transitions.

    Parameters

    The starting Vector4.

    The ending Vector4.

    t

    number

    The interpolation factor.

    Returns

    Vector4

    Returns an interpolated Vector4.

    Similar to 'Lerp' but without clamping the 't' parameter, offering more freedom in interpolation.

    Parameters

    The start Vector4.

    The end Vector4.

    t

    number

    The interpolation fraction.

    Returns

    Vector4

    Returns an unclamped interpolated Vector4.

    Moves a Vector4 'current' towards 'target', limited by 'maxDistanceDelta', useful for smooth object movement.

    Parameters

    current
    Vector4

    The current position.

    target
    Vector4

    The target position.

    maxDistanceDelta

    number

    The max distance to move.

    Returns

    Vector4

    Returns a Vector4 closer to the target.

    Multiplies two Vector4's component-wise, useful for component-wise data manipulation.

    Parameters

    The first Vector4.

    The second Vector4.

    Returns

    Vector4

    Returns a new Vector4 from component-wise multiplication.

    Normalizes a Vector4 and returns a new Vector4 with length 1, ideal for direction-only vectors.

    Parameters

    The Vector4 to normalize.

    Returns

    Vector4

    Returns a normalized Vector4.

    Computes the dot product of two Vector4's, reflecting their angular relationship.

    Parameters

    The first Vector4.

    The second Vector4.

    Returns

    number

    Returns the dot product.

    Projects a Vector4 onto another Vector4, useful for finding the nearest point on a defined line.

    Parameters

    The Vector4 to project.

    The Vector4 to project onto.

    Returns

    Vector4

    Returns the projection of 'a' onto 'b'.

    Computes the distance between two Vector4's, useful for object spacing or collision detection.

    Parameters

    The first Vector4.

    The second Vector4.

    Returns

    number

    Returns the distance between the two Vector4's.

    Calculates the length of the Vector4, useful for finding the distance it spans in 4D space.

    Parameters

    The Vector4 to compute the magnitude for.

    Returns

    number

    Returns the magnitude of the Vector4.

    Returns a Vector4 with the smallest components of two Vector4's, useful for bounding box operations.

    Parameters

    The first Vector4.

    The second Vector4.

    Returns

    Vector4

    Returns a Vector4 with the smallest components.

    Returns a Vector4 with the largest components of two Vector4's, useful for limiting operations.

    Parameters

    The first Vector4.

    The second Vector4.

    Returns

    Vector4

    Returns a Vector4 with the largest components.

    Gives the square of the magnitude of a Vector4, an efficient comparison method that avoids square root calculations.

    Parameters

    The Vector4 to square the magnitude of.

    Returns

    number

    Returns the square of the Vector4's magnitude.

    Updated 27 days ago

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.