Options
All
  • Public
  • Public/Protected
  • All
Menu

表示二维的一个向量

Class representing a vector containing 2 coordinates

Hierarchy

  • Vector2

Index

Constructors

constructor

  • Parameters

    • Optional x: number

      x value

    • Optional y: number

      y value

    Returns Vector2

  • Parameters

    • Optional point: Partial<IVec2>

      An Object that contains the values x and y

    Returns Vector2

Properties

x

x: number = ...

向量的 x 值

The X value of the current vector

default

0

y

y: number = ...

向量的 y 值

The Y value of the current vector

default

0

Static Readonly MAX

MAX: Vector2 = ...

Vector2 (Infinity, Infinity)

Static Readonly MIN

MIN: Vector2 = ...

Vector2 (-Infinity, -Infinity)

Static Readonly ONE

ONE: Vector2 = ...

Vector2 (1, 1)

Static X_DIRECTION

X_DIRECTION: Vector2 = ...

X轴正方向

The positive direction of the X-Axis

Static Y_DIRECTION

Y_DIRECTION: Vector2 = ...

Y轴正方向

The positive direction of the Y-Axis

Static Readonly ZERO

ZERO: Vector2 = ...

Vector2 (0, 0)

Accessors

angle

  • get angle(): number
  • 向量的角度

    Computes the angle in radians with respect to the horizontal left axis

    弧度制,范围在 [ 0, 2 * PI ),逆时针为正

    Radians in range [ 0, 2 * PI ), counterclockwise

    Returns number

length

  • get length(): number
  • 向量的长度

    Get the length of this vector.

    Returns number

lengthSq

  • get lengthSq(): number
  • 向量长度的平方

    Get the squared length of this vector.

    Returns number

Methods

add

  • 向量加法

    Adds v with the current vector

    Parameters

    • value: number

      a scalar or a vector2

    Returns Vector2

    A new Vector2

  • Parameters

    Returns Vector2

applyMatrix3

  • 对当前向量应用矩阵

    Apply matrix3 to the current vector

    Parameters

    Returns Vector2

    A new Vector2

clone

  • 复制当前向量

    Clones this vector to a new vector

    Returns Vector2

    新的向量 (A new Vector)

copy

  • 将向量 v 的值拷贝给当前向量

    Copies v to this vector

    Parameters

    Returns Vector2

    当前向量 (this vector2)

cross

  • 叉乘

    Computes cross product of the current vector and v

    The cross product of Vector2 is just a scalar of z-axis

    Parameters

    Returns number

divide

  • 向量除法

    Divides the current vector by v.

    Parameters

    • value: number

      a scalar or a vector2

    Returns Vector2

    A new Vector2

  • Parameters

    Returns Vector2

dot

  • 点乘

    Computes dot product of the current vector and v

    Parameters

    Returns number

equals

  • 两个向量是否相等

    Determines whether the current vector and v are equal

    Parameters

    Returns boolean

inverse

  • 逆向量

    Inverse the current vector

    Returns Vector2

    A new Vector2

isOrthogonal

  • isOrthogonal(v: Vector2, tolerance?: number): boolean
  • 两个向量是否正交垂直

    Determines whether the current vector and v are orthogonal

    Parameters

    • v: Vector2
    • tolerance: number = ...

    Returns boolean

isParallel

  • isParallel(v: Vector2, tolerance?: number): boolean
  • 两个向量是否平行

    Determines whether the current vector and v are parallel

    Parameters

    • v: Vector2
    • tolerance: number = ...

    Returns boolean

multiply

  • 向量乘法

    Multiplies the current vector by v.

    Parameters

    • value: number

      a scalar or a vector2

    Returns Vector2

    A new Vector2

  • Parameters

    Returns Vector2

normalize

  • 单位向量

    Normalizes the current vector.

    Returns Vector2

    A new Vector2

set

  • 设置向量的值

    Sets values of this vector

    Parameters

    • Optional x: number

      x value

    • Optional y: number

      y value

    Returns Vector2

    当前向量 (this vector2)

  • 设置向量的值

    Sets values of this vector

    Parameters

    • point: Partial<IVec2>

      A Object that contains the values x and y

    Returns Vector2

    当前向量 (this vector2)

setX

  • 设置向量的 x 值

    Sets the X value of this vector

    Parameters

    • x: number

    Returns Vector2

    当前向量 (this vector2)

setY

  • 设置向量的 y 值

    Sets the Y value of this vector

    Parameters

    • y: number

    Returns Vector2

    当前向量 (this vector2)

sub

  • 向量减法

    Subtracts v from the current vector

    Parameters

    • value: number

      a scalar or a vector2

    Returns Vector2

    A new Vector2

  • Parameters

    Returns Vector2

Legend

  • Constructor
  • Property
  • Method
  • Static property
  • Static method
  • Property
  • Private property

Generated using TypeDoc