目录

Vector2

Class Info

public class Vector2 implements Parcelable

二维向量。

Public Field Summary

Qualifier and Type

Field and Description

static final Vector2

ONE

二维向量Vector2(1, 1)。

static final Vector2

ZERO

0向量。

float

x

二维向量的X值。

float

y

二维向量的Y值。

Public Constructor Summary

Constructor Name

Vector2(float x, float y)

构造方法,使用X、Y值进行初始化Vector2。

Vector2(Vector2 other)

构造方法,使用其他二维向量初始化Vector2。

Public Method Summary

Qualifier and Type

Method Name and Description

static Vector2

add(Vector2 lhs, Vector2 rhs)

二维向量加法。

static float

cross(Vector2 lhs, Vector2 rhs)

二维向量叉乘。

static float

dot(Vector2 lhs, Vector2 rhs)

二维向量点乘。

float

length()

获取二维向量的模长。

Vector2

normalize()

归一化当前二维向量。

static Vector2

subtract(Vector2 lhs, Vector2 rhs)

二维向量减法。

Public Fields

[h2]ONE

Property

public static final Vector2 ONE

二维向量Vector2(1, 1)。

[h2]ZERO

Property

public static final Vector2 ZERO

0向量。

[h2]x

Property

public float x

二维向量的X值。

[h2]y

Property

public float y

二维向量的Y值。

Public Constructors

[h2]Vector2(float x, float y)

Constructor

public Vector2(float vx, float vy)

使用X、Y值进行初始化。

Parameters

Name

Description

x

二维向量的X值。

y

二维向量的Y值。

[h2]Vector2(Vector2 other)

Constructor

public Vector2(Vector2 other)

使用其他二维向量初始化。

Parameters

Name

Description

other

二维向量。

Public Methods

[h2]add

Method

public static Vector2 add(Vector2 lhs, Vector2 rhs)

二维向量加法。

Parameters

Name

Description

lhs

二维向量。

rhs

二维向量。

Returns

Type

Description

Vector2

两个二维向量的和。

[h2]cross

Method

public static float cross(Vector2 lhs, Vector2 rhs)

二维向量叉乘。

Parameters

Name

Description

lhs

二维向量。

rhs

二维向量。

Returns

Type

Description

float

两个二维向量的叉积。

[h2]dot

Method

public static float dot(Vector2 lhs, Vector2 rhs)

二维向量点乘。

Parameters

Name

Description

lhs

二维向量。

rhs

二维向量。

Returns

Type

Description

float

两个二维向量的点积。

[h2]length

Method

public float length()

获取二维向量的模长。

Returns

Type

Description

float

二维向量的模长。

[h2]normalize

Method

public Vector2 normalize()

归一化当前二维向量。

Returns

Type

Description

Vector2

归一化的二维向量。

[h2]subtract

Method

public static Vector2 subtract(Vector2 lhs, Vector2 rhs)

二维向量减法。

Parameters

Name

Description

lhs

二维向量被减数。

rhs

二维向量减数。

Returns

Type

Description

Vector2

两个二维向量的差。