@temporary-escape/mod-sdk / Vector4f
Class: Vector4f
Defined in: math/vector4f.ts:7
Constructors
Constructor
ts
new Vector4f(
x?: number,
y?: number,
z?: number,
w?: number
): Vector4f;Defined in: math/vector4f.ts:13
Parameters
| Parameter | Type | Default value |
|---|---|---|
x | number | 0 |
y | number | x |
z | number | x |
w | number | x |
Returns
Vector4f
Properties
| Property | Type | Defined in |
|---|---|---|
w | number | math/vector4f.ts:11 |
x | number | math/vector4f.ts:8 |
y | number | math/vector4f.ts:9 |
z | number | math/vector4f.ts:10 |
Methods
get()
ts
get(i: number): number;Defined in: math/vector4f.ts:42
Get an axis from the vector.
Parameters
| Parameter | Type | Description |
|---|---|---|
i | number | Axis index in range [0, 3]. |
Returns
number
set()
ts
set(i: number, v: number): void;Defined in: math/vector4f.ts:51
Set an axis value to the vector.
Parameters
| Parameter | Type | Description |
|---|---|---|
i | number | Axis index in range [0, 3]. |
v | number | Axis value. |
Returns
void
toString()
ts
toString(): string;Defined in: math/vector4f.ts:20
Returns
string
xy()
ts
xy(): Vector2f;Defined in: math/vector4f.ts:27
Returns a vector containing the x and y components of this vector.
Returns
xyz()
ts
xyz(): Vector3f;Defined in: math/vector4f.ts:34
Returns a vector containing the x, y and z components of this vector.
Returns
abs()
ts
static abs(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:185
Returns x if x >= 0; otherwise, it returns -x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
acos()
ts
static acos(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:634
Arc cosine. Returns an angle whose sine is x. The range of values returned by this function is [0, PI]. Results are undefined if |x| > 1.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
acosh()
ts
static acosh(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:642
Arc hyperbolic cosine; returns the non-negative inverse of cosh. Results are undefined if x < 1.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
add()
ts
static add(a: Vector4f, b: Vector4f): Vector4f;Defined in: math/vector4f.ts:129
Returns addition of two vectors.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
Vector4f
asin()
ts
static asin(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:652
Arc sine. Returns an angle whose sine is x. The range of values returned by this function is [-PI/2, PI/2]. Results are undefined if |x| > 1.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
asinh()
ts
static asinh(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:660
Arc hyperbolic sine Returns the inverse of sinh.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
atan()
ts
static atan(y: Vector4f, x: Vector4f): Vector4f;Defined in: math/vector4f.ts:671
Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0.
Parameters
| Parameter | Type |
|---|---|
y | Vector4f |
x | Vector4f |
Returns
Vector4f
atan2()
ts
static atan2(y: Vector4f, x: Vector4f): Vector4f;Defined in: math/vector4f.ts:612
Arc tangent. Returns an angle whose tangent is y/x. The signs of x and y are used to determine what quadrant the angle is in. The range of values returned by this function is [-PI, PI]. Results are undefined if x and y are both 0.
Parameters
| Parameter | Type |
|---|---|
y | Vector4f |
x | Vector4f |
Returns
Vector4f
atanh()
ts
static atanh(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:679
Arc hyperbolic tangent; returns the inverse of tanh. Results are undefined if abs(x) >= 1.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
ceil()
ts
static ceil(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:205
Returns a value equal to the nearest integer that is greater than or equal to x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
clamp()
ts
static clamp(
x: Vector4f,
minVal: Vector4f,
maxVal: Vector4f
): Vector4f;Defined in: math/vector4f.ts:456
Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
minVal | Vector4f |
maxVal | Vector4f |
Returns
Vector4f
cmpEqual()
ts
static cmpEqual(a: Vector4f, b: Vector4f): Vector4b;Defined in: math/vector4f.ts:171
Component-wise comparison of two vectors.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
cmpNotEqual()
ts
static cmpNotEqual(a: Vector4f, b: Vector4f): Vector4b;Defined in: math/vector4f.ts:178
Component-wise comparison of two vectors.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
cos()
ts
static cos(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:687
The standard trigonometric cosine function. The values returned by this function will range from [-1, 1].
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
cosh()
ts
static cosh(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:694
Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
degrees()
ts
static degrees(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:701
Converts radians to degrees and returns the result.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
distance()
ts
static distance(p0: Vector4f, p1: Vector4f): number;Defined in: math/vector4f.ts:468
Returns the distance between p0 and p1, i.e., length(p0 - p1).
Parameters
| Parameter | Type |
|---|---|
p0 | Vector4f |
p1 | Vector4f |
Returns
number
distance2()
ts
static distance2(p0: Vector4f, p1: Vector4f): number;Defined in: math/vector4f.ts:479
Returns the sqquared distance between p0 and p1, i.e., length2(p0 - p1).
Parameters
| Parameter | Type |
|---|---|
p0 | Vector4f |
p1 | Vector4f |
Returns
number
div()
ts
static div(a: Vector4f, b: Vector4f): Vector4f;Defined in: math/vector4f.ts:150
Returns division of two vectors.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
Vector4f
eq()
ts
static eq(a: Vector4f, b: Vector4f): boolean;Defined in: math/vector4f.ts:157
Returns true if two vectors are equal.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
boolean
exp()
ts
static exp(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:349
Returns the natural exponentiation of x, i.e., e^x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
exp2()
ts
static exp2(v: Vector4f): Vector4f;Defined in: math/vector4f.ts:356
Returns 2 raised to the v power.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
Returns
Vector4f
faceforward()
ts
static faceforward(
N: Vector4f,
I: Vector4f,
Nref: Vector4f
): Vector4f;Defined in: math/vector4f.ts:520
If dot(Nref, I) < 0.0, return N, otherwise, return -N.
Parameters
| Parameter | Type |
|---|---|
N | Vector4f |
I | Vector4f |
Nref | Vector4f |
Returns
Vector4f
floor()
ts
static floor(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:213
Returns a value equal to the nearest integer that is less then or equal to x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
fract()
ts
static fract(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:242
Return x - floor(x).
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
fromInt()
ts
static fromInt(v: Vector4i): Vector4f;Defined in: math/vector4f.ts:115
Convert a Vector4i to a Vector4f, losing precision.
Parameters
| Parameter | Type |
|---|---|
v | Vector4i |
Returns
Vector4f
inversesqrt()
ts
static inversesqrt(v: Vector4f): Vector4f;Defined in: math/vector4f.ts:364
Returns the reciprocal of the positive square root of v.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
Returns
Vector4f
isinf()
ts
static isinf(x: Vector4f): Vector4b;Defined in: math/vector4f.ts:416
Returns true if x holds a positive infinity or negative infinity representation in the underlying implementation's set of floating point representations. Returns false otherwise, including for implementations with no infinity representations.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
isnan()
ts
static isnan(x: Vector4f): Vector4b;Defined in: math/vector4f.ts:432
Returns true if x holds a NaN (not a number) representation in the underlying implementation's set of floating point representations. Returns false otherwise, including for implementations with no NaN representations.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
length()
ts
static length(x: Vector4f): number;Defined in: math/vector4f.ts:220
Returns the length of x, i.e., sqrt(x * x).
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
number
length2()
ts
static length2(x: Vector4f): number;Defined in: math/vector4f.ts:227
Returns the squared length of x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
number
log()
ts
static log(v: Vector4f): Vector4f;Defined in: math/vector4f.ts:378
Returns the natural logarithm of v, i.e., returns the value y which satisfies the equation x = e^y. Results are undefined if v <= 0.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
Returns
Vector4f
log2()
ts
static log2(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:386
Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
max()
ts
static max(x: Vector4f, y: Vector4f): Vector4f;Defined in: math/vector4f.ts:539
Returns y if x < y; otherwise, it returns x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
y | Vector4f |
Returns
Vector4f
min()
ts
static min(x: Vector4f, y: Vector4f): Vector4f;Defined in: math/vector4f.ts:527
Returns y if y < x; otherwise, it returns x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
y | Vector4f |
Returns
Vector4f
mix()
ts
static mix(
x: Vector4f,
y: Vector4f,
a: Vector4f
): Vector4f;Defined in: math/vector4f.ts:443
If genTypeU is a floating scalar or vector: Returns x * (1.0 - a) + y * a, i.e., the linear blend of x and y using the floating-point value a. The value for a is not restricted to the range [0, 1].
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
y | Vector4f |
a | Vector4f |
Returns
Vector4f
mod()
ts
static mod(x: Vector4f, y: Vector4f): Vector4f;Defined in: math/vector4f.ts:323
Modulus.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
y | Vector4f |
Returns
Vector4f
modf()
ts
static modf(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:337
Returns the fractional part of x. The integer part is not returned, as AssemblyScript has no output parameters. The return value will have the same sign as x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
mul()
ts
static mul(a: Vector4f, b: Vector4f): Vector4f;Defined in: math/vector4f.ts:143
Returns multiplication of two vectors.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
Vector4f
ne()
ts
static ne(a: Vector4f, b: Vector4f): boolean;Defined in: math/vector4f.ts:164
Returns true if two vectors are not equal.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
boolean
normalize()
ts
static normalize(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:234
Returns a vector in the same direction as x but with length of 1.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
pow()
ts
static pow(base: Vector4f, exponent: Vector4f): Vector4f;Defined in: math/vector4f.ts:393
Returns 'base' raised to the power 'exponent'.
Parameters
| Parameter | Type |
|---|---|
base | Vector4f |
exponent | Vector4f |
Returns
Vector4f
radians()
ts
static radians(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:713
Converts degrees to radians and returns the result.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
reflect()
ts
static reflect(I: Vector4f, N: Vector4f): Vector4f;Defined in: math/vector4f.ts:491
For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N.
Parameters
| Parameter | Type |
|---|---|
I | Vector4f |
N | Vector4f |
Returns
Vector4f
refract()
ts
static refract(
I: Vector4f,
N: Vector4f,
eta: number
): Vector4f;Defined in: math/vector4f.ts:506
For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector.
Parameters
| Parameter | Type |
|---|---|
I | Vector4f |
N | Vector4f |
eta | number |
Returns
Vector4f
rotate()
ts
static rotate(
v: Vector4f,
angle: number,
axis: Vector3f
): Vector4f;Defined in: math/vector4f.ts:551
Rotate a vector around an axis.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
angle | number |
axis | Vector3f |
Returns
Vector4f
rotateX()
ts
static rotateX(v: Vector4f, angle: number): Vector4f;Defined in: math/vector4f.ts:579
Rotate a vector around the X axis.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
angle | number |
Returns
Vector4f
rotateY()
ts
static rotateY(v: Vector4f, angle: number): Vector4f;Defined in: math/vector4f.ts:589
Rotate a vector around the Y axis.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
angle | number |
Returns
Vector4f
rotateZ()
ts
static rotateZ(v: Vector4f, angle: number): Vector4f;Defined in: math/vector4f.ts:599
Rotate a vector around the Z axis.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
angle | number |
Returns
Vector4f
round()
ts
static round(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:254
Returns a value equal to the nearest integer to x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
roundEven()
ts
static roundEven(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:268
Returns a value equal to the nearest integer to x. A fractional part of 0.5 will round toward the nearest even integer. (Both 3.5 and 4.5 for x will return 4.0.)
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
saturate()
ts
static saturate(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:619
Returns clamp(x, 0, 1) for each component in x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
sign()
ts
static sign(a: Vector4f): Vector4f;Defined in: math/vector4f.ts:192
Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
Returns
Vector4f
sin()
ts
static sin(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:726
The standard trigonometric sine function. The values returned by this function will range from [-1, 1].
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
sinh()
ts
static sinh(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:733
Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
smoothstep()
ts
static smoothstep(
edge0: Vector4f,
edge1: Vector4f,
x: Vector4f
): Vector4f;Defined in: math/vector4f.ts:287
Returns 0.0 if x <= edge0 and 1.0 if x >= edge1 and performs smooth Hermite interpolation between 0 and 1 when edge0 < x < edge1.
This is useful in cases where you would want a threshold function with a smooth transition. This is equivalent to: genType t; t = clamp ((x - edge0) / (edge1 - edge0), 0, 1); return t * t * (3 - 2 * t); Results are undefined if edge0 >= edge1.
Parameters
| Parameter | Type |
|---|---|
edge0 | Vector4f |
edge1 | Vector4f |
x | Vector4f |
Returns
Vector4f
sqrt()
ts
static sqrt(v: Vector4f): Vector4f;Defined in: math/vector4f.ts:405
Returns the positive square root of v.
Parameters
| Parameter | Type |
|---|---|
v | Vector4f |
Returns
Vector4f
step()
ts
static step(edge: Vector4f, x: Vector4f): Vector4f;Defined in: math/vector4f.ts:303
Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.
Parameters
| Parameter | Type |
|---|---|
edge | Vector4f |
x | Vector4f |
Returns
Vector4f
sub()
ts
static sub(a: Vector4f, b: Vector4f): Vector4f;Defined in: math/vector4f.ts:136
Returns subtraction of two vectors.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
b | Vector4f |
Returns
Vector4f
tan()
ts
static tan(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:740
The standard trigonometric tangent function.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
tanh()
ts
static tanh(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:747
Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
trunc()
ts
static trunc(x: Vector4f): Vector4f;Defined in: math/vector4f.ts:316
Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolute value of x.
Parameters
| Parameter | Type |
|---|---|
x | Vector4f |
Returns
Vector4f
unm()
ts
static unm(a: Vector4f): Vector4f;Defined in: math/vector4f.ts:122
Returns the negation of the vector.
Parameters
| Parameter | Type |
|---|---|
a | Vector4f |
Returns
Vector4f
