finds.dev← search

// the find

romainguy/kotlin-math

★ 890 · Kotlin · Apache-2.0 · updated Mar 2026

Set of Kotlin APIs to make graphics math easier to write.

A small Kotlin library of GLSL-style vector, matrix, and quaternion math types, built for graphics and shader-adjacent code (think ray tracing toys, custom renderers, or anything where you're constantly translating shader math into app code). It's aimed at Android/Kotlin devs who are tired of writing float3 math by hand with array indices.

The GLSL-mirroring API (swizzling, component aliases like .xyz/.rgb/.st, comparison functions like lessThan/greaterThan) genuinely pays off if you're porting shader code back and forth — that's a real, specific pain point this solves well. Value-type design with top-level functions instead of methods is a deliberate and sensible choice for math types that get passed around a lot. It has actual unit tests for Matrix, Quaternion, Half, and Rational, which a lot of math libraries skip. Half-precision float support is a nice touch that most Kotlin math libs don't bother with.

It's pure Kotlin with no SIMD/hardware vectorization, so if you're doing heavy per-frame math (particle systems, large meshes) this will be noticeably slower than a native or intrinsics-backed library — fine for tooling and small scenes, not for a hot render loop. The Rational type outright says in its own docs it's 'not written for speed,' which is an odd thing to ship without a faster alternative. Multiplatform support was bolted on by an external contributor (ekgame) rather than designed in from the start, so cross-platform edge cases (especially around Half on non-JVM targets) are worth testing yourself before relying on them. Documentation is just the README — no generated API docs, so anything not covered there (matrix decomposition edge cases, quaternion slerp behavior, etc.) means reading source.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →