Math

#import Builtin.Math;

Many math-related types and functions.

Functions


Vector2(x, y)

create :: Vector2(x : float, y : float)

Creates a Vector2 with the given components

Vector2I(x, y)

create :: Vector2I(x : int32, y : int32)

Creates a Vector2I with the given components

Vector3(x, y, z)

create :: Vector3(x : float, y : float, z : float)

Creates a Vector3 with the given components

Vector3I(x, y, z)

create :: Vector3I(x : int32, y : int32, z : int32)

Creates a Vector3I with the given components

Vector3I(Vector3)

create :: Vector3I(o : Vector3)

Creates a Vector3I from a Vector3

abs(int)

abs :: int(x : int)

Absolute value of an integer

abs(float)

abs :: float(x : float)

Absolute value of a float

abs(double)

abs :: double(x : double)

Absolute value of a double

clamp(float, float, float)

clamp :: float(x : float, lo : float, hi : float)

Clamps x to the range [lo, hi]

clamp(double, double, double)

clamp :: double(x : double, lo : double, hi : double)

Clamps x to the range [lo, hi]

clamp(int, int, int)

clamp :: int(x : int, lo : int, hi : int)

Clamps x to the range [lo, hi]

wrap(float, float, float)

wrap :: float(x : float, lo : float, hi : float)

Wraps x into the range [lo, hi)

wrap(double, double, double)

wrap :: double(x : double, lo : double, hi : double)

Wraps x into the range [lo, hi)

wrap(int, int, int)

wrap :: int(x : int, lo : int, hi : int)

Wraps x into the range [lo, hi)

lerp(float, float, float)

lerp :: float(a : float, b : float, t : float)

Linearly interpolates between a and b by t

lerp(double, double, double)

lerp :: double(a : double, b : double, t : double)

Linearly interpolates between a and b by t

lerp(Vector2, Vector2, float)

lerp :: Vector2(a : Vector2, b : Vector2, t : float)

Linearly interpolates between two Vector2 values

lerp(Vector3, Vector3, float)

lerp :: Vector3(a : Vector3, b : Vector3, t : float)

Linearly interpolates between two Vector3 values

Rect(x, y, width, height)

create :: Rect(x : float, y : float, width : float, height : float)

Creates a Rect with the given position and size

Structs


Vector2

2D vector with float components

Members:

Vector2.x

float

The x component of the vector

Vector2.y

float

The y component of the vector

Methods:

Vector2.normalize()

normalize :: ()

A function that will normalize the vector to a magnitude of 1. Modifies vector.

Vector2.magnitude()

magnitude :: float()

Returns the length of the vector.

Vector2I

2D vector with int32 components

Members:

Vector2I.x

int32

The x component of the vector

Vector2I.y

int32

The y component of the vector

Methods:

Vector2I.normalize()

normalize :: ()

A function that will normalize the vector to a magnitude of 1. Modifies vector.

Vector2I.magnitude()

magnitude :: float()

Returns the length of the vector.

Vector3

3D vector with float components

Members:

Vector3.x

float

The x component of the vector

Vector3.y

float

The y component of the vector

Vector3.z

float

The z component of the vector

Methods:

Vector3.normalize()

normalize :: ()

A function that will normalize the vector to a magnitude of 1. Modifies vector.

Vector3.magnitude()

magnitude :: float()

Returns the length of the vector.

Vector3I

3D vector with int32 components

Members:

Vector3I.x

int32

The x component of the vector

Vector3I.y

int32

The y component of the vector

Vector3I.z

int32

The z component of the vector

Methods:

Vector3I.normalize()

normalize :: Vector3I()

A function that will normalize the vector to a magnitude of 1. Modifies vector.

Vector3I.magnitude()

magnitude :: float()

Returns the length of the vector.

Rect

Rect defined by position and size