Utils
Cubiomes.Utils
— ModuleSome utility functions and types that are used in various places in the codebase. Ideally it should be divided into multiple very small modules.
Index
Cubiomes.Utils.findfirst_default
Cubiomes.Utils.isundef
Cubiomes.Utils.length_of_trimmed
Cubiomes.Utils.lerp
Cubiomes.Utils.lerp2
Cubiomes.Utils.lerp3
Cubiomes.Utils.lerp4
Cubiomes.Utils.threading
Cubiomes.Utils.@only_float32
API
Cubiomes.Utils.isundef
— Methodisundef(x)
Returns true if the value x
is undefined, i.e. it has not been initialized.
Cubiomes.Utils.length_of_trimmed
— Methodlength_of_trimmed(predicate, x) where N
Returns the length of the collection x
after removing the elements from the beginning and the end that satisfy the predicate
.
⚠ The collection must have the property so that x[i]
for i
in firstindex(x):lastindex(x) is valid.
Cubiomes.Utils.lerp
— Methodlerp(part, from, to)
Performs linear interpolation between from
and to
using part
as the fraction. Equivalent to from + part * (to - from)
.
Cubiomes.Utils.lerp2
— Methodlerp2(dx, dy, v00, v10, v01, v11)
Performs bilinear interpolation between four values v00
, v10
, v01
, v11
using fractions dx
and dy
.
Cubiomes.Utils.lerp3
— Methodlerp3(dx, dy, dz, v000, v100, v010, v110, v001, v101, v011, v111)
Performs trilinear interpolation between eight values v...
using fractions dx
, dy
, and dz
.
Cubiomes.Utils.lerp4
— Methodlerp4(a::Couple, b::Couple, c::Couple, d::Couple, dy, dx, dz)
Performs trilinear interpolation where the initial eight corner values are derived from four Couple
s (pairs of values) by first interpolating along the y-axis using dy
. Subsequent interpolations use dz
and dx
.
Specifically, it computes: lerp(dx, lerp(dz, lerp(dy, a[1], a[2]), lerp(dy, c[1], c[2])), lerp(dz, lerp(dy, b[1], b[2]), lerp(dy, d[1], d[2])))
Cubiomes.Utils.threading
— Functionthreading(kind = :off; kwargs...)
Return a Scheduler
from the OhMyThreads
package type that contains all the static parameters needed for threading. See the documentation of OhMyThreads related to the schedulers to know what to pass to the kwargs.
Cubiomes.Utils.@only_float32
— Macro@only_float32 expr
Transforms all real literals in the expr to Float32.
Example
@only_float32 function f()
x = 1 + 2im # expand to `1.0f0 + 2.0f0im`
x += 1 # expand to `x += 1.0f0`
return x
end
Private API
Click to see
Cubiomes.Utils.findfirst_default
— Methodfindfirst_default(predicate::Function, A, default)
Return the first index i of A where predicate(A[i]) is true. If no i satisfy this, default is returned instead.