{"id":16419673,"url":"https://github.com/nshafer/vector2","last_synced_at":"2026-02-07T11:32:45.697Z","repository":{"id":8527865,"uuid":"10144537","full_name":"nshafer/Vector2","owner":"nshafer","description":"2 Dimensional vector class for Gideros","archived":false,"fork":false,"pushed_at":"2013-06-13T17:55:50.000Z","size":128,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-02-04T16:41:12.534Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nshafer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-18T17:21:42.000Z","updated_at":"2019-08-02T20:52:04.000Z","dependencies_parsed_at":"2022-09-07T07:42:11.980Z","dependency_job_id":null,"html_url":"https://github.com/nshafer/Vector2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nshafer/Vector2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshafer%2FVector2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshafer%2FVector2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshafer%2FVector2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshafer%2FVector2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nshafer","download_url":"https://codeload.github.com/nshafer/Vector2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nshafer%2FVector2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29193598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-07T07:37:03.739Z","status":"ssl_error","status_checked_at":"2026-02-07T07:37:03.029Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11T07:25:32.492Z","updated_at":"2026-02-07T11:32:45.684Z","avatar_url":"https://github.com/nshafer.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"Vector2\n============\n\nThis is a class to facilitate two dimensional vectors in Gideros.  It is basically a table with an x and a y variable, plus support for tostring, concatenation and math operations.  It also includes methods for calculating distances to other Vector2s, arbitrary {x=x,y=y} tables, or specific points.\n\nPlease be aware that this will involve overhead versus just representing your vectors as arbitrary {x=x,y=y} tables, so it's up to you if it's worth it based on how many vectors you're creating.  All instances will include an extra reference to the metatable, so will consume a little more memory.  However, all instances will reference the same metatable, so it's just the additional table pointer itself, which will vary based on platform, but most likely no more than an int64.\n\n#Install\n\nJust add the Vector2.lua file to your project.\n\n# Example\n\n```lua\nlocal v1 = Vector2.new(1,2)\nlocal v2 = Vector2.new(3,3)\n\n-- Access the points\nprint(\"v1.x\", v1.x)\nprint(\"v1.y\", v1.y)\n\n-- Supports tostring\nprint(\"v1\", v1)\nprint(\"v2\", v2)\n\n-- Supports concatenation\nprint(\"v1: [\"..v1..\"]\")\n\n-- Supports addition\nprint(\"v1 + v2\", v1 + v2)\nprint(\"v1 + 1\", v1 + 1)\nprint(\"1 + v1\", 1 + v1)\n\n-- Supports subtraction\nprint(\"v1 - v2\", v1 - v2)\nprint(\"v1 - 1\", v1 - 1)\nprint(\"1 - v1\", 1 - v1)\n\n-- Supports multiplication\nprint(\"v1 * v2\", v1 * v2)\nprint(\"v1 * 1\", v1 * 1)\nprint(\"1 * v1\", 1 * v1)\n\n-- Supports division\nprint(\"v1 / v2\", v1 / v2)\nprint(\"v1 / 1\", v1 / 1)\nprint(\"1 / v1\", 1 / v1)\n\n-- Supports unary minus (negative)\nprint(\"-v1\", -v1)\n\n-- Supports equality testing\nprint(\"v1 == v2\", v1 == v2)\n\n-- Supports inequality testing\nprint(\"v1 ~= v2\", v1 ~= v2)\n\n-- Supports distance calculations\nprint(\"v1:distanceTo(v2)\", v1:distanceTo(v2))\n\n-- Or arbitrary points\nprint(\"v1:distanceToPoint(5,6)\", v1:distanceToPoint(5,6))\n```\n\n#Methods\n\n###Vector2.new(x, y)\nCreates a new Vector2 object.\n\nParameters:\n* x - x coordinate of the point\n* y - y coordinate of the point\n\n###Vector2:distanceTo(vector)\nReturns the distance from self to the given vector.\n\nParameters:\n* vector - A Vector2 object or table in the format {x=0,y=0}\n\n###Vector2:distanceToPoint(x, y)\nReturns the distance from self to the given point defined by x,y\n\nParameters:\n* x - x coordinate of the point\n* y - y coordinate of the point\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnshafer%2Fvector2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnshafer%2Fvector2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnshafer%2Fvector2/lists"}