Vec4 Class

Extends ValueType

Module: cc Parent Module: cc

Representation of 3D vectors and points.

Index

Properties
  • x Number
  • y Number
  • z Number
  • w Number
Methods
  • subSelf Subtracts one vector from this.
  • sub Subtracts one vector from this, and returns the new result.
  • mulSelf Multiplies this by a number.
  • mul Multiplies by a number, and returns the new result.
  • divSelf Divides by a number.
  • div Divides by a number, and returns the new result.
  • scaleSelf Multiplies two vectors.
  • scale Multiplies two vectors, and returns the new result.
  • negSelf Negates the components.
  • neg Negates the components, and returns the new result.
  • clone Obtaining copy vectors designated
  • copy Copy the target vector
  • set Set to value
  • add Element-wise vector addition
  • subtract Element-wise vector subtraction
  • multiply Element-wise vector multiplication
  • divide Element-wise vector division
  • ceil Rounding up by elements of the vector
  • floor Element vector by rounding down
  • min The minimum by-element vector
  • max The maximum value of the element-wise vector
  • round Element-wise vector of rounding to whole
  • multiplyScalar Vector scalar multiplication
  • scaleAndAdd Element-wise vector multiply add: A + B * scale
  • distance Seeking two vectors Euclidean distance
  • squaredDistance Euclidean distance squared seeking two vectors
  • len Seeking vector length
  • lengthSqr Seeking squared vector length
  • negate By taking the negative elements of the vector
  • inverse Element vector by taking the inverse, return near 0 Infinity
  • inverseSafe Element vector by taking the inverse, return near 0 0
  • normalize Normalized vector
  • dot Vector dot product (scalar product)
  • lerp Vector element by element linear interpolation: A + t * (B - A)
  • random Generates a uniformly distributed random vectors on the unit sphere
  • transformMat4 Vector matrix multiplication
  • transformQuat Vector quaternion multiplication
  • strictEquals Equivalent vectors Analyzing
  • equals Negative error vector floating point approximately equivalent Analyzing
  • toArray Vector transfer array
  • fromArray Array steering amount
  • constructor Constructor
  • clone clone a Vec4 value
  • set Set the current vector value with the given vector.
  • equals Check whether the vector equals another one
  • equals4f Check whether the vector equals another one
  • strictEquals Check whether strict equals other Vec4
  • strictEquals4f Check whether strict equals other Vec4
  • lerp Calculate linear interpolation result between this vector and another one with given ratio
  • toString Transform to string with vector informations
  • clampf Clamp the vector between minInclusive and maxInclusive.
  • addSelf Adds this vector.
  • add Adds two vectors, and returns the new result.
  • subtract Subtracts one vector from this, and returns the new result.
  • multiplyScalar Multiplies this by a number.
  • multiply Multiplies two vectors.
  • divide Divides by a number.
  • negate Negates the components.
  • dot Dot product
  • cross Cross product
  • len Returns the length of this vector.
  • lengthSqr Returns the squared length of this vector.
  • normalizeSelf Make the length of this vector to 1.
  • normalize Note that the current vector is unchanged and a new normalized vector is returned.
  • transformMat4 Transforms the vec4 with a mat4.
  • maxAxis Returns the maximum value in x, y, z, w.

Details

Properties

x
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.ts:728
y
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.ts:733
z
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.ts:738
w
meta description
Type Number
Defined in cocos2d/core/value-types/vec4.ts:743

Methods

subSelf

Subtracts one vector from this. If you want to save result to another vector, use sub() instead.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:57
Parameters
sub

Subtracts one vector from this, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:66
Parameters
  • vector Vec4
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
mulSelf

Multiplies this by a number. If you want to save result to another vector, use mul() instead.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:77
Parameters
mul

Multiplies by a number, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:86
Parameters
  • num number
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
divSelf

Divides by a number. If you want to save result to another vector, use div() instead.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:97
Parameters
div

Divides by a number, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:106
Parameters
  • num number
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
scaleSelf

Multiplies two vectors.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:117
Parameters
scale

Multiplies two vectors, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:126
Parameters
  • vector Vec4
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
negSelf

Negates the components. If you want to save result to another vector, use neg() instead.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:137
neg

Negates the components, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:145
Parameters
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
clone

Obtaining copy vectors designated

meta description
Defined in cocos2d/core/value-types/vec4.ts:165
copy

Copy the target vector

meta description
Defined in cocos2d/core/value-types/vec4.ts:177
set

Set to value

meta description
Defined in cocos2d/core/value-types/vec4.ts:193
add

Element-wise vector addition

meta description
Defined in cocos2d/core/value-types/vec4.ts:209
subtract

Element-wise vector subtraction

meta description
Defined in cocos2d/core/value-types/vec4.ts:225
multiply

Element-wise vector multiplication

meta description
Defined in cocos2d/core/value-types/vec4.ts:241
divide

Element-wise vector division

meta description
Defined in cocos2d/core/value-types/vec4.ts:257
ceil

Rounding up by elements of the vector

meta description
Defined in cocos2d/core/value-types/vec4.ts:273
floor

Element vector by rounding down

meta description
Defined in cocos2d/core/value-types/vec4.ts:289
min

The minimum by-element vector

meta description
Defined in cocos2d/core/value-types/vec4.ts:305
max

The maximum value of the element-wise vector

meta description
Defined in cocos2d/core/value-types/vec4.ts:321
round

Element-wise vector of rounding to whole

meta description
Defined in cocos2d/core/value-types/vec4.ts:337
multiplyScalar

Vector scalar multiplication

meta description
Defined in cocos2d/core/value-types/vec4.ts:353
scaleAndAdd

Element-wise vector multiply add: A + B * scale

meta description
Defined in cocos2d/core/value-types/vec4.ts:369
distance

Seeking two vectors Euclidean distance

meta description
Defined in cocos2d/core/value-types/vec4.ts:385
squaredDistance

Euclidean distance squared seeking two vectors

meta description
Defined in cocos2d/core/value-types/vec4.ts:401
len

Seeking vector length

meta description
Defined in cocos2d/core/value-types/vec4.ts:417
lengthSqr

Seeking squared vector length

meta description
Defined in cocos2d/core/value-types/vec4.ts:433
negate

By taking the negative elements of the vector

meta description
Defined in cocos2d/core/value-types/vec4.ts:449
inverse

Element vector by taking the inverse, return near 0 Infinity

meta description
Defined in cocos2d/core/value-types/vec4.ts:465
inverseSafe

Element vector by taking the inverse, return near 0 0

meta description
Defined in cocos2d/core/value-types/vec4.ts:481
normalize

Normalized vector

meta description
Defined in cocos2d/core/value-types/vec4.ts:522
dot

Vector dot product (scalar product)

meta description
Defined in cocos2d/core/value-types/vec4.ts:546
lerp

Vector element by element linear interpolation: A + t * (B - A)

meta description
Defined in cocos2d/core/value-types/vec4.ts:558
random

Generates a uniformly distributed random vectors on the unit sphere

meta description
Defined in cocos2d/core/value-types/vec4.ts:574
Parameters
  • scale Unknown 生成的向量长度
transformMat4

Vector matrix multiplication

meta description
Defined in cocos2d/core/value-types/vec4.ts:597
transformQuat

Vector quaternion multiplication

meta description
Defined in cocos2d/core/value-types/vec4.ts:637
strictEquals

Equivalent vectors Analyzing

meta description
Defined in cocos2d/core/value-types/vec4.ts:667
equals

Negative error vector floating point approximately equivalent Analyzing

meta description
Defined in cocos2d/core/value-types/vec4.ts:679
toArray

Vector transfer array

meta description
Defined in cocos2d/core/value-types/vec4.ts:694
Parameters
  • ofs Unknown 数组起始偏移量
fromArray

Array steering amount

meta description
Defined in cocos2d/core/value-types/vec4.ts:711
Parameters
  • ofs Unknown 数组起始偏移量
constructor

Constructor see Cc/vec4:method

meta description
Defined in cocos2d/core/value-types/vec4.ts:748
Parameters
clone

clone a Vec4 value

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:775
set

Set the current vector value with the given vector.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:785
Parameters
  • newValue Vec4 !#en new value to set. !#zh 要设置的新值
equals

Check whether the vector equals another one

meta description
Returns Boolean
Defined in cocos2d/core/value-types/vec4.ts:811
Parameters
equals4f

Check whether the vector equals another one

meta description
Returns Boolean
Defined in cocos2d/core/value-types/vec4.ts:826
Parameters
  • x number 相比较的向量的 x 分量。
  • y number 相比较的向量的 y 分量。
  • z number 相比较的向量的 z 分量。
  • w number 相比较的向量的 w 分量。
  • epsilon number 允许的误差,应为非负数。
strictEquals

Check whether strict equals other Vec4

meta description
Returns boolean
Defined in cocos2d/core/value-types/vec4.ts:844
Parameters
  • other Vec4 相比较的向量。
strictEquals4f

Check whether strict equals other Vec4

meta description
Returns boolean
Defined in cocos2d/core/value-types/vec4.ts:855
Parameters
  • x number 指定向量的 x 分量。
  • y number 指定向量的 y 分量。
  • z number 指定向量的 z 分量。
  • w number 指定向量的 w 分量。
lerp

Calculate linear interpolation result between this vector and another one with given ratio

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:869
Parameters
  • to Vec4 目标向量。
  • ratio number 插值比率,范围为 [0,1]。
toString

Transform to string with vector informations

meta description
Returns string
Defined in cocos2d/core/value-types/vec4.ts:889
clampf

Clamp the vector between minInclusive and maxInclusive.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:899
Parameters
  • minInclusive Vec4 每个分量都代表了对应分量允许的最小值。
  • maxInclusive Vec4 每个分量都代表了对应分量允许的最大值。
addSelf

Adds this vector. If you want to save result to another vector, use add() instead.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:915
Parameters
add

Adds two vectors, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:931
Parameters
  • vector Vec4
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
subtract

Subtracts one vector from this, and returns the new result.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:948
Parameters
  • vector Vec4
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
multiplyScalar

Multiplies this by a number.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:965
Parameters
multiply

Multiplies two vectors.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:981
Parameters
divide

Divides by a number.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:997
Parameters
negate

Negates the components.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:1013
dot

Dot product

meta description
Returns number
Defined in cocos2d/core/value-types/vec4.ts:1028
Parameters
cross

Cross product

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:1039
Parameters
len

Returns the length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec4.ts:1058
Examples
var v = cc.v4(10, 10);
v.len(); // return 14.142135623730951;
lengthSqr

Returns the squared length of this vector.

meta description
Returns number
Defined in cocos2d/core/value-types/vec4.ts:1075
normalizeSelf

Make the length of this vector to 1.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:1089
normalize

Returns this vector with a magnitude of 1.

Note that the current vector is unchanged and a new normalized vector is returned. If you want to normalize the current vector, use normalizeSelf function.

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:1101
Parameters
  • out Vec4 optional, the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
transformMat4

Transforms the vec4 with a mat4. 4th vector component is implicitly '1'

meta description
Returns Vec4
Defined in cocos2d/core/value-types/vec4.ts:1131
Parameters
  • m Mat4 matrix to transform with
  • out Vec4 the receiving vector, you can pass the same vec4 to save result to itself, if not provided, a new vec4 will be created
maxAxis

Returns the maximum value in x, y, z, w.

meta description
Returns number
Defined in cocos2d/core/value-types/vec4.ts:1152

results matching ""

    No results matching ""