Skip to content

Maths

These glyphs represent some basic mathematical operations. While not needed for all enchantments, more complex spellforms do rely on these for their correct functioning. While often limited to number species, some glyphs in this section also apply to vector species.

num|vec$() → num|vec$() Returns the additive inverse of the head, equivalent to multiplying by -1.

For vectors, this operation is applied to each component (as per multiplication by -1).

num|vec, num|vec$() → num|vec$() Pops two number or vector species, adds them, and pushes the result. Behaviour changes depending on popped species.

Two numbers: num, num → num Standard addition.

Two vectors: vec, vec → vec Standard vector addition.

Vec & Num: vec, num → vec Regardless of order, adds the number to each of the vector’s components.

num|vec, num|vec$() → num|vec$() Subtracts the species at the head from the species below it. Behaviour changes depending on popped species.

Two numbers: num, num → num Subtract head from number below it.

Two vectors: vec, vec → vec Subtract head from vector below it.

Vec & Num: vec, num → vec Subtract number from each of the vector’s components.

num|vec, num|vec$() → num|vec$() Multiplies the top two species. Behaviour changes depending on popped species.

Two numbers: num, num → num Standard multiplication.

Two vectors: vec, vec → vec Take the dot product of both vectors.

Vec & Num: vec, num → vec Order-insensitive, scale the vector by the number.

num|vec, num|vec$() → num|vec$() Divides the species below the head by the species at the head. Behaviour changes depending on popped species. Do not divide by 0.

Two Nums: num1, num2 → num Returns num1/num2, where num2 was at the head.

Two Vecs: vec1, vec2 → vec Takes the cross product vec1 x vec 2, where vec2 was at the head.

Vec & Num: vec, num → vec Scales the vector by the reciprocal of the number. (eg. A, 4 → A scaled by 1/4)

num, num, num$() → num$() Uses the head and the number below it to adjust the number at the third place on the capsum.

Consider the case x$(), a$(), b$():

If x$() is within [a$(), b$()], then the glyph returns x$().

If x$() < a$(), returns a$().

If x$() > b$(), returns b$().

num|vec, num|vec, num|vec$() → num|vec$() Moves from the third value to the second value by the amount specified by the head.

Standard equation: a$(), b$(), t$() → a$() + t$() x (b$() - a$())

For numbers, apply the standard equation.

For cases where a$() & b$() are vectors, applies the standard equation using vector operations.

For all vectors, applies the standard equation per axis (on a1, b1 and t1, so on and so forth), returning the resulting vector.

num|vec, num$() → num|vec$() Takes the modulus of the species below the head with respect to the head (the remainder from division).

If the number below the head is a vector, the modulus of each component with respect to the number is taken.

num, num$() → num$() Exponentiates the number below the head by the head.

eg. a$(), b$() → a$()^b$()

num$() → num$() Pops a number, rounds it down if possible, and pushes the result onto the capsum.

num$() → num$() Pops a number, rounds it up if possible, and pushes the result onto the capsum.

num$() → num$() Pops a number, rounds it according to the standard method, and pushes the result onto the capsum.

num|vec$() → num|vec$() Pops the top species and returns the absolute value.

For vectors, the glyph takes the absolute value of each component and returns the resulting vector.

num$() → num$() Pops a number, and pushes onto the capsum either -1, 0 or 1 depending on whether the popped number was negative, zero or positive.

num, num$() → num$() Pops two numbers and pushes only the smallest of the two onto the capsum.

num, num$() → num$() Pops two numbers and pushes only the largest of the two onto the capsum.