{"id":29360223,"url":"https://github.com/bbredesen/vkm","last_synced_at":"2025-07-09T07:12:16.946Z","repository":{"id":111583620,"uuid":"298907716","full_name":"bbredesen/vkm","owner":"bbredesen","description":"A simple Go language matrix and vector math module, targeting 3D graphics. ","archived":false,"fork":false,"pushed_at":"2023-03-05T21:57:39.000Z","size":27,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-06-21T10:59:09.245Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","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/bbredesen.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":"2020-09-26T22:10:40.000Z","updated_at":"2023-03-04T03:07:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"8b145e35-4db5-4f62-9960-540d1e45ea97","html_url":"https://github.com/bbredesen/vkm","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":"0.15384615384615385","last_synced_commit":"9f013d7c43f5b8b7ae8fb12de37c5e3c5ac94a7a"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/bbredesen/vkm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbredesen%2Fvkm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbredesen%2Fvkm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbredesen%2Fvkm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbredesen%2Fvkm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bbredesen","download_url":"https://codeload.github.com/bbredesen/vkm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bbredesen%2Fvkm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264411192,"owners_count":23603807,"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":"2025-07-09T07:12:16.224Z","updated_at":"2025-07-09T07:12:16.936Z","avatar_url":"https://github.com/bbredesen.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VKM\n\nVKM is a simple vector and matrix math package written in Go, inspired by glm,\nand targeting 3D graphics programing. \n\nVKM is specifically targeted at 3D graphics and is NOT inteded to be an\nall-purpose vector math or linear algebra package. It includes some variant types like `Pt2` and\n`Vec3` for convenience, but the primary matrix math functions rely on homogenous 3D\nvectors and points.\n\nWhile this module can be used in any Go program wanting to work with 3D transformations, it was built to use with\n[go-vk](https://github.com/bbredesen/go-vk), a Go\nlanguage binding for the [Vulkan](https://khronos.org/vulkan/) graphics API.\n\n## Usage\n\nSee the GoDoc for the full API.\n\nVKM defines three primary types: `Pt`, `Vec`, and `Matrix`. All three are stored\nin column-major order and are fundamentally arrays of `[4]float32`. (Note: this explicitly means static arrays and not\nslices.) \n\nWe use `float32`, and not Go's default 64-bit floating point type, because Vulkan (generally) uses 32-bit\nfloats on the GPU. As a consequence, and rather than constantly forcing float32 type casts, VKM uses the [chewxy/math32 package](https://github.com/chewxy/math32) for float32 operations and constants. \n\n## Examples\n\n### Create a basic transformation\nYou can generate a simple tranformation with the `NewMat__` variants:\n\n```go\nimport \"github.com/bbredesen/vkm\"\n// ...\ntransVec := vkm.NewVec(-1, -2, -3)\ntransMat := vkm.NewMatTranslate(transVec)\n```\n\nRotations are measured in radians by default, but each rotation function has a\n\"Deg\" variant to use degrees. Rotation angles will scale with the length of the axis vector, so be sure to\nnormalize the vector first:\n\n```go\nimport \"github.com/chewxy/math32\"\n// ...\naxisVec := vkm.NewVec(1, 1, 1).Normalize()\naRotationMat := vkm.NewMatRotate(axisVec, math32.Pi)\n```\n\n### Multiply arbitrary matricies and points or vectors\n\nMatrix multiplication happens in the order written when you directly call\n`MultM`, `MultV`, or `MultP`. The following code has the apparent\neffect of rotating the world before translating:\n```go\ntransformMat := myTranslationMat.MultM(myRotationMat)\n```\n\n### Create a \"readable\" transformation\nTransformations can be chained, as long as you have a matrix to start from. In\nthis example, we apply a translation of -5 in the X direction, rotate around the\nY axis by 45 degrees counterclockwise, and then translate by +5 in the X\ndirection:\n```go\ntransVec := NewVec(-5, 0, 0)\n\nm := Identity().\n    Translate(transVec).\n    RotateYDeg(-45).\n    Translate(transVec.Invert())\n```\nWhen written in this form, we apply transformations in the order they are\nwritten. In practice, the code is actually right-multiplying each subsequent\ntransformation, as in the previous example.\n\n## Performance Optimization TODO\n\nAll math in this library is currently writing in pure Go. Performance could benefit from using SIMD extensions on\nIntel/AMD CPUs, which will require writing those functions in assembly.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbredesen%2Fvkm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbredesen%2Fvkm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbredesen%2Fvkm/lists"}