Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Absolute2DPosition

Absolute cartesian 2D position. This class implements a Vector2. This location can be used both as an absolute location or relative location.

Hierarchy

Implements

Index

Constructors

constructor

Properties

accuracy

accuracy: number

Position accuracy

height

height: number

Readonly isVector2

isVector2: true

orientation

orientation: Orientation

Orientation at recorded position

referenceSpaceUID

referenceSpaceUID: string

Position reference space UID

timestamp

timestamp: number = ...

Position recording timestamp

unit

unit: LengthUnit = ...

Position unit

velocity

velocity: Velocity = ...

Velocity at recorded position

deprecated

use linearVelocity and angularVelocity instead

width

width: number

x

x: number

y

y: number

Accessors

angularVelocity

linearVelocity

Methods

add

  • Adds v to this vector.

    Parameters

    • v: Vector2
    • Optional w: Vector2

    Returns Absolute2DPosition

addScalar

  • Adds the scalar value s to this vector's x and y values.

    Parameters

    • s: number

    Returns Absolute2DPosition

addScaledVector

addVectors

  • Sets this vector to a + b.

    Parameters

    • a: Vector2
    • b: Vector2

    Returns Absolute2DPosition

angle

  • angle(): number
  • computes the angle in radians with respect to the positive x-axis

    Returns number

angleTo

applyMatrix3

  • Multiplies this vector (with an implicit 1 as the 3rd component) by m.

    Parameters

    • m: Matrix3

    Returns Absolute2DPosition

ceil

  • The x and y components of the vector are rounded up to the nearest integer value.

    Returns Absolute2DPosition

clamp

  • If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value. If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.

    Parameters

    • min: Vector2

      the minimum x and y values.

    • max: Vector2

      the maximum x and y values in the desired range.

    Returns Absolute2DPosition

clampLength

  • If this vector's length is greater than the max value, it is replaced by the max value. If this vector's length is less than the min value, it is replaced by the min value.

    Parameters

    • min: number

      the minimum value the length will be clamped to.

    • max: number

      the maximum value the length will be clamped to.

    Returns Absolute2DPosition

clampScalar

  • If this vector's x or y values are greater than the max value, they are replaced by the max value. If this vector's x or y values are less than the min value, they are replaced by the min value.

    Parameters

    • min: number

      the minimum value the components will be clamped to.

    • max: number

      the maximum value the components will be clamped to.

    Returns Absolute2DPosition

clone

copy

  • Copies value of v to this vector.

    Parameters

    • v: Vector2

    Returns Absolute2DPosition

cross

  • cross(v: Vector2): number
  • Computes cross product of this vector and v.

    Parameters

    • v: Vector2

    Returns number

distanceTo

distanceToManhattan

  • distanceToManhattan(v: Vector2): number
  • deprecated

    Use {@link Vector2#manhattanDistanceTo .manhattanDistanceTo()} instead.

    Parameters

    • v: Vector2

    Returns number

distanceToSquared

  • distanceToSquared(v: Vector2): number
  • Computes squared distance of this vector to v.

    Parameters

    • v: Vector2

    Returns number

divide

  • Divides this vector by v.

    Parameters

    • v: Vector2

    Returns Absolute2DPosition

divideScalar

  • Divides this vector by scalar s. Set vector to ( 0, 0 ) if s == 0.

    Parameters

    • s: number

    Returns Absolute2DPosition

dot

  • dot(v: Vector2): number
  • Computes dot product of this vector and v.

    Parameters

    • v: Vector2

    Returns number

equals

floor

  • The components of the vector are rounded down to the nearest integer value.

    Returns Absolute2DPosition

fromArray

  • Sets this vector's x and y value from the provided array or array-like.

    Parameters

    • array: number[] | ArrayLike<number>

      the source array or array-like.

    • Optional offset: number

      (optional) offset into the array. Default is 0.

    Returns Absolute2DPosition

fromBufferAttribute

  • Sets this vector's x and y values from the attribute.

    Parameters

    • attribute: BufferAttribute

      the source attribute.

    • index: number

      index in the attribute.

    Returns Absolute2DPosition

fromVector

getComponent

  • getComponent(index: number): number
  • Gets a component of this vector.

    Parameters

    • index: number

    Returns number

length

  • length(): number
  • Computes length of this vector.

    Returns number

lengthManhattan

  • lengthManhattan(): number
  • deprecated

    Use {@link Vector2#manhattanLength .manhattanLength()} instead.

    Returns number

lengthSq

  • lengthSq(): number
  • Computes squared length of this vector.

    Returns number

lerp

  • Linearly interpolates between this vector and v, where alpha is the distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.

    Parameters

    • v: Vector2

      vector to interpolate towards.

    • alpha: number

      interpolation factor in the closed interval [0, 1].

    Returns Absolute2DPosition

lerpVectors

  • Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.

    Parameters

    • v1: Vector2

      the starting vector.

    • v2: Vector2

      vector to interpolate towards.

    • alpha: number

      interpolation factor in the closed interval [0, 1].

    Returns Absolute2DPosition

manhattanDistanceTo

  • manhattanDistanceTo(v: Vector2): number

manhattanLength

  • manhattanLength(): number

max

  • If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.

    Parameters

    • v: Vector2

    Returns Absolute2DPosition

min

  • If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.

    Parameters

    • v: Vector2

    Returns Absolute2DPosition

multiply

  • Multiplies this vector by v.

    Parameters

    • v: Vector2

    Returns Absolute2DPosition

multiplyScalar

negate

normalize

random

  • Sets this vector's x and y from Math.random

    Returns Absolute2DPosition

rotateAround

  • Rotates the vector around center by angle radians.

    Parameters

    • center: Vector2

      the point around which to rotate.

    • angle: number

      the angle to rotate, in radians.

    Returns Absolute2DPosition

round

  • The components of the vector are rounded to the nearest integer value.

    Returns Absolute2DPosition

roundToZero

  • The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.

    Returns Absolute2DPosition

set

  • Sets value of this vector.

    Parameters

    • x: number
    • y: number

    Returns Absolute2DPosition

setComponent

  • Sets a component of this vector.

    Parameters

    • index: number
    • value: number

    Returns Absolute2DPosition

setLength

  • Normalizes this vector and multiplies it by l.

    Parameters

    • length: number

    Returns Absolute2DPosition

setScalar

  • Sets the x and y values of this vector both equal to scalar.

    Parameters

    • scalar: number

    Returns Absolute2DPosition

setX

  • Sets X component of this vector.

    Parameters

    • x: number

    Returns Absolute2DPosition

setY

  • Sets Y component of this vector.

    Parameters

    • y: number

    Returns Absolute2DPosition

sub

  • Subtracts v from this vector.

    Parameters

    • v: Vector2

    Returns Absolute2DPosition

subScalar

  • Subtracts s from this vector's x and y components.

    Parameters

    • s: number

    Returns Absolute2DPosition

subVectors

  • Sets this vector to a - b.

    Parameters

    • a: Vector2
    • b: Vector2

    Returns Absolute2DPosition

toArray

  • toArray(array?: number[], offset?: number): number[]
  • toArray(array?: Vector2Tuple, offset?: 0): Vector2Tuple
  • toArray(array: ArrayLike<number>, offset?: number): ArrayLike<number>
  • Returns an array [x, y], or copies x and y into the provided array.

    Parameters

    • Optional array: number[]

      (optional) array to store the vector to. If this is not provided, a new array will be created.

    • Optional offset: number

      (optional) optional offset into the array.

    Returns number[]

    The created or provided array.

  • Parameters

    • Optional array: Vector2Tuple
    • Optional offset: 0

    Returns Vector2Tuple

  • Copies x and y into the provided array-like.

    Parameters

    • array: ArrayLike<number>

      array-like to store the vector to.

    • Optional offset: number

      (optional) optional offset into the array.

    Returns ArrayLike<number>

    The provided array-like.

toVector3

Static fromArray

  • fromArray(array: number[]): Vector2