module

Geode

Mathematics library supporting vectors, matrices, quaternions, and more.

Constants

VERSION = {{ (`shards version \"/tmp/tmp.JGhadg/src/src\"`).stringify.chomp }}

Current version of the Geode library.

Class methods

edge(value : T, edge) forall T

Returns 0 if the value is less than the edge value or 1 if it's greater.

0.edge(1) # => 0
2.edge(1) # => 1
Source
lerp(a, b, t : Number)

Calculates the linear interpolation between two values.

t is a value from 0 to 1, where 0 represents a and 1 represents b. Any value between 0 and 1 will result in a proportional amount of a and b.

This method uses the precise calculation that does not suffer precision loss from high exponential differences.

Source
max(a : CommonMatrix(T, M, N), b : CommonMatrix(U, M, N)) : CommonMatrix forall T, U, M, N

Returns a new matrix with the maximum element from each matrix.

Geode.max(Matrix[[1, 2], [3, 4]], Matrix[[4, 3], [2, 1]]) # => [[4, 3], [3, 4]]
Source
max(matrix : CommonMatrix(T, M, N), value : U) : CommonMatrix forall T, U, M, N

Returns a new matrix with the greater value of the element or value.

Geode.max(Matrix[[1, 2], [3, 4]], 2) # => [[2, 2], [3, 4]]
Source
max(a : CommonVector(T, N), b : CommonVector(U, N)) : CommonVector forall T, U, N

Returns a new vector with the maximum component from each vector.

Geode.max(Vector[1, 2, 3], Vector[3, 2, 1]) # => (3, 2, 3)
Source
max(vector : CommonVector(T, N), value : U) : CommonVector forall T, U, N

Returns a new vector with the greater value of the component or value.

Geode.max(Vector[1, 2, 3], 2) # => (2, 2, 3)
Source
min(a : CommonMatrix(T, M, N), b : CommonMatrix(U, M, N)) : CommonMatrix forall T, U, M, N

Returns a new matrix with the minimum element from each matrix.

Geode.min(Matrix[[1, 2], [3, 4]], Matrix[[4, 3], [2, 1]) # => [[1, 2], [2, 1 ]]
Source
min(matrix : CommonMatrix(T, M, N), value : U) : CommonMatrix forall T, U, M, N

Returns a new matrix with the lesser value of the element or value.

Geode.min(Matrix[[1, 2], [3, 4]], 2) # => [[1, 2], [2, 2]]
Source
min(a : CommonVector(T, N), b : CommonVector(U, N)) : CommonVector forall T, U, N

Returns a new vector with the minimum component from each vector.

Geode.min(Vector[1, 2, 3], Vector[3, 2, 1]) # => (1, 2, 1)
Source
min(vector : CommonVector(T, N), value : U) : CommonVector forall T, U, N

Returns a new vector with the lesser value of the component or value.

Geode.min(Vector[1, 2, 3], 2) # => (1, 2, 2)
Source

Nested types