Math

#import Builtin.Math;

Many math-related types and functions.

Functions


Vector2(x, y)

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

Creates a Vector2 with the given components

Vector2I(x, y)

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

Creates a Vector2I with the given components

Vector3(x, y, z)

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

Creates a Vector3 with the given components

string(vec3)

cast :: string(v : const Vector3)

Converts a Vector3 into its string representation

string(vec3i)

cast :: string(v : const Vector3I)

Converts a Vector3I into its string representation

Vector3I(x, y, z)

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

Creates a Vector3I with the given components

Vector3I(Vector3)

create :: Vector3I(o : const Vector3)

Creates a Vector3I from a Vector3

==(Vector3I, Vector3I)

operator== :: bool(l : const Vector3I, r : const Vector3I)

Compares two Vector3I's to see if they are equal

abs(int)

abs :: int(x : const int)

Absolute value of an integer

abs(float)

abs :: float(x : const float)

Absolute value of a float

abs(double)

abs :: double(x : const double)

Absolute value of a double

clamp(float, float, float)

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

Clamps x to the range [lo, hi]

clamp(double, double, double)

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

Clamps x to the range [lo, hi]

clamp(int, int, int)

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

Clamps x to the range [lo, hi]

wrap(float, float, float)

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

Wraps x into the range [lo, hi)

wrap(double, double, double)

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

Wraps x into the range [lo, hi)

wrap(int, int, int)

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

Wraps x into the range [lo, hi)

lerp(float, float, float)

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

Linearly interpolates between a and b by t

lerp(double, double, double)

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

Linearly interpolates between a and b by t

lerp(Vector2, Vector2, float)

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

Linearly interpolates between two Vector2 values

lerp(Vector3, Vector3, float)

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

Linearly interpolates between two Vector3 values

Rect(x, y, width, height)

create :: Rect(x : const float, y : const float, width : const float, height : const 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

Constants


PI 3.14159265358979323846
const double
TAU 6.28318530717958647692
const double
E 2.71828182845904523536
const double