{"id":16405616,"url":"https://github.com/aecsocket/klam","last_synced_at":"2025-02-23T19:23:48.140Z","repository":{"id":152068935,"uuid":"616665512","full_name":"aecsocket/klam","owner":"aecsocket","description":"Linear algebra library for Kotlin","archived":false,"fork":false,"pushed_at":"2023-07-29T16:24:21.000Z","size":317,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-05T11:42:51.261Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aecsocket.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-20T20:48:46.000Z","updated_at":"2023-03-20T20:49:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"5cbcaf24-bc29-48e3-aac3-9ac84bd6923b","html_url":"https://github.com/aecsocket/klam","commit_stats":{"total_commits":70,"total_committers":2,"mean_commits":35.0,"dds":"0.014285714285714235","last_synced_commit":"b6d7ecc8f110f2c458de0920ca6bf935de352795"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fklam","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fklam/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fklam/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aecsocket%2Fklam/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aecsocket","download_url":"https://codeload.github.com/aecsocket/klam/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240366019,"owners_count":19790009,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T06:06:42.761Z","updated_at":"2025-02-23T19:23:48.091Z","avatar_url":"https://github.com/aecsocket.png","language":"Kotlin","readme":"\u003cdiv align=\"center\"\u003e\n\n# Klam\n[![CI](https://img.shields.io/github/actions/workflow/status/aecsocket/klam/build.yml)](https://github.com/aecsocket/klam/actions/workflows/build.yml)\n[![Release](https://img.shields.io/maven-central/v/io.github.aecsocket/klam?label=release)](https://central.sonatype.com/artifact/io.github.aecsocket/klam)\n[![Snapshot](https://img.shields.io/nexus/s/io.github.aecsocket/klam?label=snapshot\u0026server=https%3A%2F%2Fs01.oss.sonatype.org)](https://central.sonatype.com/artifact/io.github.aecsocket/klam)\n\nLinear algebra library for 2D/3D applications\n\n### [GitHub](https://github.com/aecsocket/glossa) · [Dokka](https://aecsocket.github.io/klam/dokka)\n\n\u003c/div\u003e\n\nInspired by the [glam Rust crate](https://crates.io/crates/glam/),\n[glm C++ library](https://github.com/g-truc/glm),\n[kotlin-math library](https://github.com/romainguy/kotlin-math/), `klam` offers a simple and\nperformant linear algebra API and classes. The classes and methods are mostly modelled after GLSL\nsymbols - notably, many functions are defined as top-level functions instead of methods.\n\nThis library also offers support for the [Configurate](https://github.com/spongepowered/configurate)\nserialization library through `klam-configurate`.\n\n## Usage\n\nSee the version badges for the latest release and snapshot builds.\n\nModules:\n- `klam` - core API\n- `klam-configurate` - tools for the [Configurate](https://github.com/spongepowered/configurate)\n  library\n\n```kotlin\nrepositories {\n  mavenCentral()\n  // for snapshot builds\n  // maven(\"https://s01.oss.sonatype.org/content/repositories/snapshots/\")\n}\n\ndependencies {\n  implementation(\"io.github.aecsocket\", \"klam\", \"VERSION\")\n}\n```\n\n### Types\n\nThe various types are defined in a specific format:\n- Element type\n  - `B` boolean\n  - `I` integer\n  - `L` long\n  - `F` float\n  - `D` double\n- Structure\n  - `(T)Vec(2|3|4)` vector\n  - `(T)Mat(2|3|4)` NxN matrix\n  - `(T)Quat` quaternion\n  - `(T)Iso3` isometric transformation (position + rotation)\n  - `(T)Affine3` affine transformation (position + rotation + scale)\n  - `(T)Ray` half-infinite line (origin + direction)\n\nAll classes are immutable.\n\n### Methods\n\n#### Construction\n\n`Vec` types can be constructed by specifying:\n* all components\n```kotlin\nval vec = FVec2(0.5f, 1.5f, 2.5f)\n```\n\n* a single scalar, duplicated across all components\n```kotlin\nval vec = DVec3(0.0)\n```\n\n`Mat` types can be constructed by specifying:\n* the vectors (in **column-major** order)\n```kotlin\nval mat = IMat2(\n    IVec2(0, 1),\n    IVec2(2, 3),\n)\n// [\n//   0 2\n//   1 3\n// ]\n```\n\n* the individual elements (in **row-major** order)\n```kotlin\nval mat = IMat2(\n    0, 1,\n    2, 3,\n)\n// [\n//   0 1\n//   2 3\n// ]\n```\n\n#### Accessors\n\n`Vec` types have element accessors in `xyzw`, `rgba` and `stpq` forms:\n```kotlin\nval vec = IVec4(0, 1, 2, 3)\nassertEquals(vec.x == vec.r == vec.s) // 0\nassertEquals(vec.y == vec.g == vec.t) // 1\nassertEquals(vec.z == vec.b == vec.p) // 2\nassertEquals(vec.w == vec.a == vec.q) // 3\n\nvec.r = 5 // x = 5\nvec.q = 10 // w = 10\n```\n\n`Vec` types can be swizzled in any permutation:\n```kotlin\nval vec = IVec3(0, 1, 2)\nvec.yx // (1, 0)\nvec.zzzz // (2, 2, 2, 2)\nvec.rbg // (0, 2, 1)\n```\n\n`Vec` and `Quat` types have element index operators:\n```kotlin\nval vec = FVec4(0.5f, 1.0f, 1.5f, 2.0f)\nval quat = FQuat(0.5f, 1.0f, 1.5f, 2.0f)\nassertEquals(vec[0] == quat[0]) // 0.5\nassertEquals(vec[1] == quat[1]) // 1.0\n\nvec[0] = quat[3] // vec.x = 2.0f\n```\n\n`Mat` types can be indexed by column (returning a `Vec`) or by column and row (returning a scalar):\n```kotlin\nval mat = IMat2.identity // IMat2(1, 0, 0, 1)\nmat[0] // IVec2(1, 0)\nmat[0, 0] // 1\nmat[0, 1] // 0\n```\n\n### Operators\n\nAll types have algebraic operator functions:\n```kotlin\nval v1 = IVec2(1, 2) + IVec2(4, 5) // (5, 7)\nval v2 = FQuat(0.0f, 0.0f, 0.0f, 1.0f) * FVec3(1.0f, 1.0f, 1.0f) // (1.0, 1.0, 1.0)\n```\n\nTransformations, such as `Mat * Mat` or `Quat * Vec`, are done through the `*` (times) operator.\n\n### Functions\n\nAll type-specific functions are declared as top-level functions:\n```kotlin\nval v1 = FVec3(0.5f, 0.5f, 0.5f)\nval v2 = FVec3(0.2f, 0.2f, 0.2f)\n\nval theDot = dot(v1, v2)\nval theCross = cross(v1, v2)\n\nval q = DQuat(0.0, 0.0, 0.0, 1.0)\nval qInv = inverse(q)\n```\n\n### Rotations\n\n`Vec`, `Mat` and `Quat` types are all capable of representing rotations as Euler angles, rotation\nmatrices and quaternions respectively. They can be converted between using the top-level functions:\n* `asQuat(...)` : `*Quat`\n* `asMatrix(...)` : `*Mat3`\n* `asEuler(...)` : `*Vec3`\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faecsocket%2Fklam","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faecsocket%2Fklam","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faecsocket%2Fklam/lists"}