@bedrock-oss/bedrock-boost
    Preparing search index...

    Class Vec2

    Implements

    • Vector2
    Index

    Constructors

    • Parameters

      • x: number
      • y: number

      Returns Vec2

    • Parameters

      Returns Vec2

    • Parameters

      Returns Vec2

    • Parameters

      • x: Vector2

      Returns Vec2

    • Parameters

      • x: Direction

      Returns Vec2

    • Parameters

      • x: number[]

      Returns Vec2

    Properties

    x: number

    X component of the two-dimensional vector.

    y: number

    Y component of the two-dimensional vector.

    East: Vec2
    North: Vec2
    South: Vec2
    West: Vec2
    Zero: Vec2

    Methods

    • Adds another vector to the current vector.

      Parameters

      • x: number
      • y: number

      Returns Vec2

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      Returns Vec2

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: Vector2

      Returns Vec2

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: VectorXZ

      Returns Vec2

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: Direction

      Returns Vec2

      The updated vector after addition.

    • Adds another vector to the current vector.

      Parameters

      • x: number[]

      Returns Vec2

      The updated vector after addition.

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number
      • y: number
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Vec2
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Vector2
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: VectorXZ
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Direction
      • delta: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number[]
      • delta: number

      Returns boolean

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: number
      • y: number

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: Vector2

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: Direction

      Returns number

      The angle in radians between the two vectors.

    • Computes the angle (in radians) between the current vector and another vector.

      Parameters

      • x: number[]

      Returns number

      The angle in radians between the two vectors.

    • Ceils the X, Y, and Z components of the vector.

      Returns Vec2

      A new vector with the ceiled components.

    • Ceils the X component of the vector.

      Returns Vec2

      A new vector with the ceiled X component.

    • Ceils the Y component of the vector.

      Returns Vec2

      A new vector with the ceiled Y component.

    • Creates a copy of the current vector.

      Returns Vec2

      A new vector with the same values as the current vector.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: number
      • y: number

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: Vector2

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: VectorXZ

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: Direction

      Returns number

      The distance between the two vectors.

    • Computes the distance between the current vector and another vector.

      Parameters

      • x: number[]

      Returns number

      The distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: number
      • y: number

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: Vector2

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: VectorXZ

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: Direction

      Returns number

      The squared distance between the two vectors.

    • Computes the squared distance between the current vector and another vector. This is faster than computing the actual distance and can be useful for comparison purposes.

      Parameters

      • x: number[]

      Returns number

      The squared distance between the two vectors.

    • Calculates the shortest distance between a point (represented by this Vector3 instance) and a line segment.

      This method finds the perpendicular projection of the point onto the line defined by the segment. If this projection lies outside the line segment, then the method calculates the distance from the point to the nearest segment endpoint.

      Parameters

      • start: Vector2

        The starting point of the line segment.

      • end: Vector2

        The ending point of the line segment.

      Returns number

      The shortest distance between the point and the line segment.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: number
      • y: number

      Returns Vec2

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      Returns Vec2

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: Vector2

      Returns Vec2

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: VectorXZ

      Returns Vec2

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: Direction

      Returns Vec2

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: number[]

      Returns Vec2

      The updated vector after division.

    • Divides the current vector by another vector or scalar.

      Parameters

      • x: number

      Returns Vec2

      The updated vector after division.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: number
      • y: number

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: Vector2

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: VectorXZ

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: Direction

      Returns number

      The dot product of the two vectors.

    • Computes the dot product of the current vector with another vector.

      Parameters

      • x: number[]

      Returns number

      The dot product of the two vectors.

    • Returns a new vector offset from the current vector east by 1 block.

      Returns Vec2

      A new vector offset from the current vector east by 1 block.

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number
      • y: number

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Vector2

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: VectorXZ

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: Direction

      Returns boolean

    • Checks if the current vector is equal to another vector.

      Parameters

      • x: number[]

      Returns boolean

    • Floors the X, Y, and Z components of the vector.

      Returns Vec2

      A new vector with the floored components.

    • Floors the X component of the vector.

      Returns Vec2

      A new vector with the floored X component.

    • Floors the Y component of the vector.

      Returns Vec2

      A new vector with the floored Y component.

    • Checks if the current vector is equal to the zero vector.

      Returns boolean

      true if the vector is equal to the zero vector, else returns false.

    • Computes the length (magnitude) of the vector.

      Returns number

      The length of the vector.

    • Computes the squared length of the vector. This is faster than computing the actual length and can be useful for comparison purposes.

      Returns number

      The squared length of the vector.

    • Computes the linear interpolation between the current vector and another vector, when t is in the range [0, 1]. Computes the extrapolation when t is outside this range.

      Parameters

      • v: Vector2

        The other vector.

      • t: number

        The interpolation factor.

      Returns Vec2

      A new vector after performing the lerp operation.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: number
      • y: number

      Returns Vec2

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      Returns Vec2

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: Vector2

      Returns Vec2

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: VectorXZ

      Returns Vec2

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: Direction

      Returns Vec2

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: number[]

      Returns Vec2

      The updated vector after multiplication.

    • Multiplies the current vector by another vector or scalar.

      Parameters

      • x: number

      Returns Vec2

      The updated vector after multiplication.

    • Normalizes the vector to have a length (magnitude) of 1. Normalized vectors are often used as a direction vectors.

      Returns Vec2

      The normalized vector.

    • Returns a new vector offset from the current vector north by 1 block.

      Returns Vec2

      A new vector offset from the current vector north by 1 block.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: number
      • y: number

      Returns Vec2

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      Returns Vec2

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: Vector2

      Returns Vec2

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: VectorXZ

      Returns Vec2

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: Direction

      Returns Vec2

      A new vector representing the projection of the current vector onto v.

    • Computes the projection of the current vector onto another vector. This method finds how much of the current vector lies in the direction of vector v.

      Parameters

      • x: number[]

      Returns Vec2

      A new vector representing the projection of the current vector onto v.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: number
      • y: number

      Returns Vec2

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      Returns Vec2

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: Vector2

      Returns Vec2

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: VectorXZ

      Returns Vec2

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: Direction

      Returns Vec2

      A new vector representing the reflection of the current vector.

    • Computes the reflection of the current vector against a normal vector. Useful for simulating light reflections or bouncing objects.

      Parameters

      • x: number[]

      Returns Vec2

      A new vector representing the reflection of the current vector.

    • Rounds the X, Y, and Z components of the vector.

      Returns Vec2

      A new vector with the rounded components.

    • Rounds the X component of the vector.

      Returns Vec2

      A new vector with the rounded X component.

    • Rounds the Y component of the vector.

      Returns Vec2

      A new vector with the rounded Y component.

    • Scales the current vector by a scalar.

      Parameters

      • scalar: number

      Returns Vec2

      The updated vector after scaling.

    • Sets the X component of the vector.

      Parameters

      • value: number

        The new X value.

      Returns Vec2

      The updated vector with the new X value.

    • Sets the Y component of the vector.

      Parameters

      • value: number

        The new Y value.

      Returns Vec2

      The updated vector with the new Y value.

    • Computes the spherical linear interpolation between the current vector and another vector, when t is in the range [0, 1]. Computes the extrapolation when t is outside this range.

      Parameters

      • v: Vector2

        The other vector.

      • t: number

        The interpolation factor.

      Returns Vec2

      A new vector after performing the slerp operation.

    • Returns a new vector offset from the current vector south by 1 block.

      Returns Vec2

      A new vector offset from the current vector south by 1 block.

    • Subtracts another vector from the current vector.

      Parameters

      • x: number
      • y: number

      Returns Vec2

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      Returns Vec2

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: Vector2

      Returns Vec2

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: VectorXZ

      Returns Vec2

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: Direction

      Returns Vec2

      The updated vector after subtraction.

    • Subtracts another vector from the current vector.

      Parameters

      • x: number[]

      Returns Vec2

      The updated vector after subtraction.

    • Converts the vector to an array containing the X, Y, and Z components of the vector.

      Returns number[]

      An array containing the X, Y, and Z components of the vector.

    • Returns a new vector with the X, Y, and Z components rounded to the nearest block location.

      Returns Vec2

    • Converts the vector to a direction. If the vector is not a unit vector, then it will be normalized and rounded to the nearest direction.

      Returns Direction

    • Creates a mutable copy of the current vector.

      Returns MutVec2

      A mutable vector with the same values as the current vector.

    • Returns a string representation of an object.

      Parameters

      • Optionalformat: "long" | "short"
      • Optionalseparator: string

      Returns string

    • Converts the current vector to a 3d vetor with the given y-value.

      Parameters

      • Optionalz: number

        The optional z value for the 3d vetor.

      Returns Vec3

      The converted vector.

    • Converts the normal vector to yaw and pitch values.

      Returns number

      A Vector2 containing the yaw and pitch values.

    • Returns a new vector offset from the current vector west by 1 block.

      Returns Vec2

      A new vector offset from the current vector west by 1 block.

    • Creates a new vector from the given values.

      Parameters

      • x: number
      • y: number

      Returns Vec2

    • Creates a new vector from the given values.

      Parameters

      Returns Vec2

    • Creates a new vector from the given values.

      Parameters

      • x: Vector2

      Returns Vec2

    • Creates a new vector from the given values.

      Parameters

      • x: VectorXZ

      Returns Vec2

    • Creates a new vector from the given values.

      Parameters

      • x: Direction

      Returns Vec2

    • Creates a new vector from the given values.

      Parameters

      • x: number[]

      Returns Vec2

    • Creates a new direction vector from yaw rotation.

      Parameters

      • yaw: number

        The yaw value in degrees.

      Returns Vec2

      A new vector representing the direction.