KKKIIO/selene/math does not have a README file
pub(all) enum RepeatMode {
RepeatX
RepeatY
NoRepeat
Repeat
}pub(all) struct Transform {
a : Double
b : Double
c : Double
d : Double
tx : Double
ty : Double
}let v1 = @math.Vec2(3.0, 4.0)
let v2 = @math.Vec2::zero()
inspect(v1[X], content="3")
inspect(v1[Y], content="4")
inspect(v2[X], content="0")
inspect(v2[Y], content="0")let v = @math.Vec2(3.0, 4.0)
inspect(v.distance(), content="5") // sqrt(3² + 4²) = 5let v1 = @math.Vec2(0.0, 0.0)
let v2 = @math.Vec2(3.0, 4.0)
inspect(v1.distance_to(v2), content="5")let v1 = @math.Vec2(3.0, 4.0)
let v2 = @math.Vec2(2.0, 1.0)
inspect(v1.dot(v2), content="10") // 3*2 + 4*1 = 10let v = @math.Vec2(3.0, 4.0)
let normalized = v.normalize()
inspect(normalized.distance(), content="1") // Unit vector has magnitude 1let v = @math.Vec2(3.0, 4.0)
let updated_x = v.update(X, 10.0)
let updated_y = v.update(Y, 20.0)
inspect(updated_x, content="Vec2(10, 4)")
inspect(updated_y, content="Vec2(3, 20)")fn normalize_angle(angle : Double) -> Double// Positive angle greater than 2PI
inspect(@cmath.normalize_angle(7.0), content="0.7168146928204138")
// Negative angle
inspect(@cmath.normalize_angle(-1.0), content="5.283185307179586")
// Angle already in range
inspect(@cmath.normalize_angle(1.5), content="1.5")ECS game engine in MoonBit
Dependencies