Skip to content

@temporary-escape/mod-sdk / Vector2f

Class: Vector2f ​

Defined in: math/vector2f.ts:5

Constructors ​

Constructor ​

ts
new Vector2f(x?: number, y?: number): Vector2f;

Defined in: math/vector2f.ts:9

Parameters ​

ParameterTypeDefault value
xnumber0
ynumberx

Returns ​

Vector2f

Properties ​

PropertyTypeDefined in
xnumbermath/vector2f.ts:6
ynumbermath/vector2f.ts:7

Methods ​

get() ​

ts
get(i: number): number;

Defined in: math/vector2f.ts:22

Get an axis from the vector.

Parameters ​

ParameterTypeDescription
inumberAxis index in range [0, 1].

Returns ​

number


set() ​

ts
set(i: number, v: number): void;

Defined in: math/vector2f.ts:31

Set an axis value to the vector.

Parameters ​

ParameterTypeDescription
inumberAxis index in range [0, 1].
vnumberAxis value.

Returns ​

void


toString() ​

ts
toString(): string;

Defined in: math/vector2f.ts:14

Returns ​

string


abs() ​

ts
static abs(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:161

Returns x if x >= 0; otherwise, it returns -x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


acos() ​

ts
static acos(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:474

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 ​

ParameterType
xVector2f

Returns ​

Vector2f


acosh() ​

ts
static acosh(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:482

Arc hyperbolic cosine; returns the non-negative inverse of cosh. Results are undefined if x < 1.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


add() ​

ts
static add(a: Vector2f, b: Vector2f): Vector2f;

Defined in: math/vector2f.ts:105

Returns addition of two vectors.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

Vector2f


asin() ​

ts
static asin(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:492

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 ​

ParameterType
xVector2f

Returns ​

Vector2f


asinh() ​

ts
static asinh(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:500

Arc hyperbolic sine Returns the inverse of sinh.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


atan() ​

ts
static atan(y: Vector2f, x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:511

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 ​

ParameterType
yVector2f
xVector2f

Returns ​

Vector2f


atan2() ​

ts
static atan2(y: Vector2f, x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:457

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 ​

ParameterType
yVector2f
xVector2f

Returns ​

Vector2f


atanh() ​

ts
static atanh(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:519

Arc hyperbolic tangent; returns the inverse of tanh. Results are undefined if abs(x) >= 1.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


ceil() ​

ts
static ceil(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:176

Returns a value equal to the nearest integer that is greater than or equal to x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


clamp() ​

ts
static clamp(
   x: Vector2f, 
   minVal: Vector2f, 
   maxVal: Vector2f
): Vector2f;

Defined in: math/vector2f.ts:370

Returns min(max(x, minVal), maxVal) for each component in x using the floating-point values minVal and maxVal.

Parameters ​

ParameterType
xVector2f
minValVector2f
maxValVector2f

Returns ​

Vector2f


cmpEqual() ​

ts
static cmpEqual(a: Vector2f, b: Vector2f): Vector2b;

Defined in: math/vector2f.ts:147

Component-wise comparison of two vectors.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

Vector2b


cmpNotEqual() ​

ts
static cmpNotEqual(a: Vector2f, b: Vector2f): Vector2b;

Defined in: math/vector2f.ts:154

Component-wise comparison of two vectors.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

Vector2b


cos() ​

ts
static cos(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:527

The standard trigonometric cosine function. The values returned by this function will range from [-1, 1].

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


cosh() ​

ts
static cosh(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:534

Returns the hyperbolic cosine function, (exp(x) + exp(-x)) / 2.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


degrees() ​

ts
static degrees(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:541

Converts radians to degrees and returns the result.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


distance() ​

ts
static distance(p0: Vector2f, p1: Vector2f): number;

Defined in: math/vector2f.ts:380

Returns the distance between p0 and p1, i.e., length(p0 - p1).

Parameters ​

ParameterType
p0Vector2f
p1Vector2f

Returns ​

number


distance2() ​

ts
static distance2(p0: Vector2f, p1: Vector2f): number;

Defined in: math/vector2f.ts:389

Returns the sqquared distance between p0 and p1, i.e., length2(p0 - p1).

Parameters ​

ParameterType
p0Vector2f
p1Vector2f

Returns ​

number


div() ​

ts
static div(a: Vector2f, b: Vector2f): Vector2f;

Defined in: math/vector2f.ts:126

Returns division of two vectors.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

Vector2f


eq() ​

ts
static eq(a: Vector2f, b: Vector2f): boolean;

Defined in: math/vector2f.ts:133

Returns true if two vectors are equal.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

boolean


exp() ​

ts
static exp(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:283

Returns the natural exponentiation of x, i.e., e^x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


exp2() ​

ts
static exp2(v: Vector2f): Vector2f;

Defined in: math/vector2f.ts:290

Returns 2 raised to the v power.

Parameters ​

ParameterType
vVector2f

Returns ​

Vector2f


faceforward() ​

ts
static faceforward(
   N: Vector2f, 
   I: Vector2f, 
   Nref: Vector2f
): Vector2f;

Defined in: math/vector2f.ts:423

If dot(Nref, I) < 0.0, return N, otherwise, return -N.

Parameters ​

ParameterType
NVector2f
IVector2f
NrefVector2f

Returns ​

Vector2f


floor() ​

ts
static floor(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:184

Returns a value equal to the nearest integer that is less then or equal to x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


fract() ​

ts
static fract(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:213

Return x - floor(x).

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


fromInt() ​

ts
static fromInt(v: Vector2i): Vector2f;

Defined in: math/vector2f.ts:91

Convert a Vector2i to a Vector2f, losing precision.

Parameters ​

ParameterType
vVector2i

Returns ​

Vector2f


inversesqrt() ​

ts
static inversesqrt(v: Vector2f): Vector2f;

Defined in: math/vector2f.ts:298

Returns the reciprocal of the positive square root of v.

Parameters ​

ParameterType
vVector2f

Returns ​

Vector2f


isinf() ​

ts
static isinf(x: Vector2f): Vector2b;

Defined in: math/vector2f.ts:340

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 ​

ParameterType
xVector2f

Returns ​

Vector2b


isnan() ​

ts
static isnan(x: Vector2f): Vector2b;

Defined in: math/vector2f.ts:351

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 ​

ParameterType
xVector2f

Returns ​

Vector2b


length() ​

ts
static length(x: Vector2f): number;

Defined in: math/vector2f.ts:191

Returns the length of x, i.e., sqrt(x * x).

Parameters ​

ParameterType
xVector2f

Returns ​

number


length2() ​

ts
static length2(x: Vector2f): number;

Defined in: math/vector2f.ts:198

Returns the squared length of x.

Parameters ​

ParameterType
xVector2f

Returns ​

number


log() ​

ts
static log(v: Vector2f): Vector2f;

Defined in: math/vector2f.ts:307

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 ​

ParameterType
vVector2f

Returns ​

Vector2f


log2() ​

ts
static log2(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:315

Returns the base 2 log of x, i.e., returns the value y, which satisfies the equation x = 2 ^ y.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


max() ​

ts
static max(x: Vector2f, y: Vector2f): Vector2f;

Defined in: math/vector2f.ts:437

Returns y if x < y; otherwise, it returns x.

Parameters ​

ParameterType
xVector2f
yVector2f

Returns ​

Vector2f


min() ​

ts
static min(x: Vector2f, y: Vector2f): Vector2f;

Defined in: math/vector2f.ts:430

Returns y if y < x; otherwise, it returns x.

Parameters ​

ParameterType
xVector2f
yVector2f

Returns ​

Vector2f


mix() ​

ts
static mix(
   x: Vector2f, 
   y: Vector2f, 
   a: Vector2f
): Vector2f;

Defined in: math/vector2f.ts:362

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 ​

ParameterType
xVector2f
yVector2f
aVector2f

Returns ​

Vector2f


mod() ​

ts
static mod(x: Vector2f, y: Vector2f): Vector2f;

Defined in: math/vector2f.ts:267

Modulus.

Parameters ​

ParameterType
xVector2f
yVector2f

Returns ​

Vector2f


modf() ​

ts
static modf(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:276

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 ​

ParameterType
xVector2f

Returns ​

Vector2f


mul() ​

ts
static mul(a: Vector2f, b: Vector2f): Vector2f;

Defined in: math/vector2f.ts:119

Returns multiplication of two vectors.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

Vector2f


ne() ​

ts
static ne(a: Vector2f, b: Vector2f): boolean;

Defined in: math/vector2f.ts:140

Returns true if two vectors are not equal.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

boolean


normalize() ​

ts
static normalize(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:205

Returns a vector in the same direction as x but with length of 1.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


pow() ​

ts
static pow(base: Vector2f, exponent: Vector2f): Vector2f;

Defined in: math/vector2f.ts:322

Returns 'base' raised to the power 'exponent'.

Parameters ​

ParameterType
baseVector2f
exponentVector2f

Returns ​

Vector2f


radians() ​

ts
static radians(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:548

Converts degrees to radians and returns the result.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


reflect() ​

ts
static reflect(I: Vector2f, N: Vector2f): Vector2f;

Defined in: math/vector2f.ts:399

For the incident vector I and surface orientation N, returns the reflection direction : result = I - 2.0 * dot(N, I) * N.

Parameters ​

ParameterType
IVector2f
NVector2f

Returns ​

Vector2f


refract() ​

ts
static refract(
   I: Vector2f, 
   N: Vector2f, 
   eta: number
): Vector2f;

Defined in: math/vector2f.ts:409

For the incident vector I and surface normal N, and the ratio of indices of refraction eta, return the refraction vector.

Parameters ​

ParameterType
IVector2f
NVector2f
etanumber

Returns ​

Vector2f


rotate() ​

ts
static rotate(v: Vector2f, angle: number): Vector2f;

Defined in: math/vector2f.ts:444

Rotate a vector.

Parameters ​

ParameterType
vVector2f
anglenumber

Returns ​

Vector2f


round() ​

ts
static round(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:220

Returns a value equal to the nearest integer to x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


roundEven() ​

ts
static roundEven(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:229

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 ​

ParameterType
xVector2f

Returns ​

Vector2f


saturate() ​

ts
static saturate(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:464

Returns clamp(x, 0, 1) for each component in x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


sign() ​

ts
static sign(a: Vector2f): Vector2f;

Defined in: math/vector2f.ts:168

Returns 1.0 if x > 0, 0.0 if x == 0, or -1.0 if x < 0.

Parameters ​

ParameterType
aVector2f

Returns ​

Vector2f


sin() ​

ts
static sin(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:559

The standard trigonometric sine function. The values returned by this function will range from [-1, 1].

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


sinh() ​

ts
static sinh(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:566

Returns the hyperbolic sine function, (exp(x) - exp(-x)) / 2.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


smoothstep() ​

ts
static smoothstep(
   edge0: Vector2f, 
   edge1: Vector2f, 
   x: Vector2f
): Vector2f;

Defined in: math/vector2f.ts:243

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 ​

ParameterType
edge0Vector2f
edge1Vector2f
xVector2f

Returns ​

Vector2f


sqrt() ​

ts
static sqrt(v: Vector2f): Vector2f;

Defined in: math/vector2f.ts:329

Returns the positive square root of v.

Parameters ​

ParameterType
vVector2f

Returns ​

Vector2f


step() ​

ts
static step(edge: Vector2f, x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:252

Returns 0.0 if x < edge, otherwise it returns 1.0 for each component of a genType.

Parameters ​

ParameterType
edgeVector2f
xVector2f

Returns ​

Vector2f


sub() ​

ts
static sub(a: Vector2f, b: Vector2f): Vector2f;

Defined in: math/vector2f.ts:112

Returns subtraction of two vectors.

Parameters ​

ParameterType
aVector2f
bVector2f

Returns ​

Vector2f


tan() ​

ts
static tan(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:573

The standard trigonometric tangent function.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


tanh() ​

ts
static tanh(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:580

Returns the hyperbolic tangent function, sinh(angle) / cosh(angle)

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


trunc() ​

ts
static trunc(x: Vector2f): Vector2f;

Defined in: math/vector2f.ts:260

Returns a value equal to the nearest integer to x whose absolute value is not larger than the absolute value of x.

Parameters ​

ParameterType
xVector2f

Returns ​

Vector2f


unm() ​

ts
static unm(a: Vector2f): Vector2f;

Defined in: math/vector2f.ts:98

Returns the negation of the vector.

Parameters ​

ParameterType
aVector2f

Returns ​

Vector2f