{"id":15014669,"url":"https://github.com/syndyr/luavector","last_synced_at":"2026-01-05T00:13:02.538Z","repository":{"id":77251336,"uuid":"229060401","full_name":"Syndyr/LuaVector","owner":"Syndyr","description":"A universal vector library verified compatible with all major Lua versions","archived":false,"fork":false,"pushed_at":"2019-12-19T15:15:21.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-22T13:16:41.076Z","etag":null,"topics":["axis","bottomright","delta","distance","inbounds","love2d","love2d-framework","love2d-library","lua","lua-library","vector","vector-math"],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Syndyr.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":"2019-12-19T13:28:56.000Z","updated_at":"2021-01-26T20:24:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"e09881af-75e7-4a0d-9da4-e566c588f4da","html_url":"https://github.com/Syndyr/LuaVector","commit_stats":{"total_commits":5,"total_committers":2,"mean_commits":2.5,"dds":0.4,"last_synced_commit":"cf822e1e8a7b33cfa137912e5865a3a8ae69fb97"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndyr%2FLuaVector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndyr%2FLuaVector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndyr%2FLuaVector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Syndyr%2FLuaVector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Syndyr","download_url":"https://codeload.github.com/Syndyr/LuaVector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244959457,"owners_count":20538629,"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":["axis","bottomright","delta","distance","inbounds","love2d","love2d-framework","love2d-library","lua","lua-library","vector","vector-math"],"created_at":"2024-09-24T19:45:56.547Z","updated_at":"2026-01-05T00:13:02.511Z","avatar_url":"https://github.com/Syndyr.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LuaVector\nA universal vector library verified compatible with all major Lua versions and does not require any services like LuaRocks or external libraries.\n\nThis library is intended to be used for 2D applications primarily but the Vector metatype supports 3D math, this includes all mathematical operands and boolean operators.\n\n\n## Implementation\nImplementation is as simple as requiring the library.\n\nIn this example the library is located in a \"libs\" file in the project root directory.\n\n```\nrequire \"libs.vector\"\n```\n\n## Vector creation\nYou can create a Vector using both a long and short function in the following manners.\nAll vectors are created with three axis entries, x, y and z, by default these values are 0 unless stated otherwise during creation.\n\n```\nmyVector = Vector() --The same as doing Vector(0, 0, 0)\nmyShortVector = v() --The same as doing v(0, 0, 0)\n```\n\n\n## Vector math and comparisons\n\nVectors can be manipulated like a normal number with no need for special considerations. This includes adding/subtracting/multiplying/dividing/modding/power Vectors together.\n\nYou can also add/subtract/multiply/divide/modulo/power a Vector with a normal number.\n```\nmyVector = Vector(2, 2, 2) + Vector(1, 1, 1) --\u003e [3, 3, 3]\nmyVector = Vector(2, 2, 2) - Vector(1, 1, 1) --\u003e [1, 1, 1]\nmyVector = Vector(2, 2, 2) * Vector(2, 2, 2) --\u003e [4, 4, 4]\nmyVector = Vector(2, 2, 2) / Vector(2, 2, 2) --\u003e [1, 1, 1]\nmyVector = Vector(7, 8, 11) % Vector(3, 5, 6) --\u003e [1, 3, 5]\nmyVector = Vector(2, 2, 2) ^ Vector(2, 3, 4) --\u003e [4, 8, 16]\n\n\nmyVector = Vector(2, 2, 2) + 1 --\u003e [3, 3, 3]\nmyVector = Vector(2, 2, 2) - 1 --\u003e [1, 1, 1]\nmyVector = Vector(2, 2, 2) * 2 --\u003e [4, 4, 4]\nmyVector = Vector(2, 2, 2) / 2 --\u003e [1, 1, 1]\nmyVector = Vector(7, 8, 11) % 3 --\u003e [1, 2, 2]\nmyVector = Vector(2, 2, 2) ^ 4 --\u003e [16, 16, 16]\n```\n\nVectors can be compared against each other as well and requires all digits to meet the comparison criteria.\n\n## Other functions\nThis is a list of various utility and \"nice to have\" functions included in this library.\n\n### self[Vector]:dist(target[Vector])\nThis is a function for getting the distance between two points in space and is the only supplied function that uses all three axis available.\n##### Returns\n- Distance[Number]\n- Delta[Vector]\n\nDistance is the linear distance between points.\n\nDelta is the cartesian delta between x1 -\u003e x2, y1 -\u003e y2 and z1 -\u003e z2.\n\n\n\n### self[Vector]:inBounds2D(bottomRight[Vector], point[Vector])\n\nThis allows for a crude and quick 2D bounds check, it will check that point[Vector] is within the points defined by self[Vector] and bottomRight[Vector].\n\n##### Returns\n- inBounds[Boolean]\n\nInbounds states if point[Vector] is within the bounds of self[Vector] and bottomRight[Vector].\n\n\n\n### self[Vector]:bearing2D(target[Vector])\nThis does a quick calculation to find the bearing between self[Vector] and target[Vector]. \n\n##### Returns\n- Bearing[number]\n- Distance[Number]\n- Delta[Vector]\n\nBearing is the bearing between self[Vector] and target[Vector].\n\nDistance is the linear distance between points.\n\nDelta is the cartesian delta between x1 -\u003e x2, y1 -\u003e y2 and z1 -\u003e z2.\n\n### self[Vector]:tangent2D(target[Vector], distance[Number])\nIt does what it says. I'm not too sure how, I was mildly intoxicate when I wrote this.\n\n\n\n\n\n### self[Vector]:toString(round[Boolean])\nFormats the x, y and z to a human readable format.\n\n##### Returns\n- String[String]\n\n### self[Vector]:splitxyz(round[Boolean])\nSplits and returns self[Vector]'s x, y and z components as numbers.\n\n##### returns\n- X[Number]\n- Y[Number]\n- Z[Number]\n\n### self[Vector]:x/y/z(set[Number])\nOperates as separate get/set functions for the axis they denote.\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyndyr%2Fluavector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyndyr%2Fluavector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyndyr%2Fluavector/lists"}