{"id":17668500,"url":"https://github.com/evanshortiss/vector2d","last_synced_at":"2025-12-12T03:58:29.394Z","repository":{"id":8968658,"uuid":"10710548","full_name":"evanshortiss/vector2d","owner":"evanshortiss","description":"2D Vector Library. Operates using Objects, Array or Float32Array types to allow flexible performance.","archived":false,"fork":false,"pushed_at":"2023-11-22T05:44:44.000Z","size":425,"stargazers_count":32,"open_issues_count":2,"forks_count":9,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-07T13:41:58.625Z","etag":null,"topics":["2d","2d-vector-library","javascript","math","nodejs","typescript","vec2d","vector","vector-representations","vector2d","vectors"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/evanshortiss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","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}},"created_at":"2013-06-15T18:55:30.000Z","updated_at":"2024-09-23T20:57:47.000Z","dependencies_parsed_at":"2022-08-31T04:22:14.613Z","dependency_job_id":"5c3f8847-78a9-493d-9211-d676abf014cd","html_url":"https://github.com/evanshortiss/vector2d","commit_stats":{"total_commits":80,"total_committers":3,"mean_commits":"26.666666666666668","dds":0.35,"last_synced_commit":"84970f88fc93c8cccd2f84a63896b7021656123a"},"previous_names":["evanshortiss/vec2d"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanshortiss%2Fvector2d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanshortiss%2Fvector2d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanshortiss%2Fvector2d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evanshortiss%2Fvector2d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evanshortiss","download_url":"https://codeload.github.com/evanshortiss/vector2d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249110228,"owners_count":21214296,"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":["2d","2d-vector-library","javascript","math","nodejs","typescript","vec2d","vector","vector-representations","vector2d","vectors"],"created_at":"2024-10-23T23:22:47.603Z","updated_at":"2025-12-12T03:58:29.323Z","avatar_url":"https://github.com/evanshortiss.png","language":"TypeScript","readme":"# Vector2D - 2D Vectors for TypeScript \u0026 JavaScript\n\n[![Travis CI](https://travis-ci.org/evanshortiss/vector2d.svg?branch=master)](https://travis-ci.org/evanshortiss/vector2d)\n[![Coverage Status](https://coveralls.io/repos/github/evanshortiss/vector2d/badge.svg?branch=master)](https://coveralls.io/github/evanshortiss/vector2d?branch=master)\n[![TypeScript](https://badges.frapsoft.com/typescript/code/typescript.svg?v=101)](https://github.com/ellerbrock/typescript-badges/)\n\n## Documentation\n\nDetailed documentation is available [here](http://evanshortiss.com/vector2d/).\n\n## Installation and Usage\n\nInstall via npm:\n\n```bash\nnpm install vector2d\n```\n\nUsage with JavaScript:\n\n```js\nvar Vec2D = require('vector2d');\n\nconst v = new Vec2D.Vector(2, 3)\n```\n\nUsage with TypeScript/ES6:\n\n```ts\nimport * as Vec2D from 'vector2d'\n\nconst v = new Vec2D.Vector(2, 3)\n```\n\nIt's also possible to use this module directly in the browser through\n`window.Vec2D`. Simply clone the code locally and run the following:\n\n```\nnpm install\nnpm run browserify\nnpm run uglify\n```\n\nThis will produce `vec2d.js` and `vec2d.min.js` files in `dist/` the folder of\nthe repository that you can include via `\u003cscript\u003e` tags.\n\n## About\nAn easy to use 2D Vector library with 3 methods of Vector representation to\noptimise for your particular use case.\n\nVector2D provides 3 main modes of Vector representations (classes):\n\n* Vec2D.ArrayVector\n* Vec2D.Float32Vector\n* Vec2D.Vector\n\nThe different representations is really more of an experiment than a necessity\nsince for most users `Vector` or `ArrayVector` types will be fine.\n\nRegardless of the class used all methods can be used in the same manner and\nyou don't need to worry about the underlying representation.\n\n## API\n\n### Vector Instance Methods\nAll instance methods modify the underlying vector where possible. For example\ncalling *multiplyByScalar* will multiply the vector x and y components by the\nprovided number and return the updated vector itself (a reference to *this*)\nrather than a new instance. The benefit if this is that less objects are created\nwhich reduces garbage collection and makes chaining possible.\n\nIf you don't want to modfy the vector itself you can call `v.clone()` and modify\nthe newly returned vector instead. Here's an example.\n\n```js\nconst av0 = new Vec2D.ArrayVector(10, 0)\nconst av1 = new Vec2D.ArrayVector(0, 5)\n\n// Methods are chainable where you'd expect\nconst newVec = av0.clone().add(av1);\nnewVec.toString(); // (10, 5)\n\n// Original vector hasn't changed!\nav0.toString(); // (10, 0)\n```\n\n\n#### setAxes(x, y)\nSet the x and y values of this vector.\n\n#### toString()\nConvert vector to a String with format \"(0, 0)\"\n\n#### toArray()\nConvert vector to standard JavaScript Array [2.823, 1.541]\n\n#### toObject()\nCovert vector to a JSON object with format { x: 1.4, y: 8 }.\n\n#### add(vector)\nModify this vector by adding the provided vector to it.\n\n#### subtract(vector)\nModify this vector by subtracting the provided vector from it.\n\n#### equals(vector)\nCheck does this vector equal the provided vector.\n\n#### mulV(vector)\nMultiply this vector by provided vector.\n\n#### divV(vector)\nDivide this vector by provided vector.\n\n#### mulS(number)\nMultiply this vector by a number.\n\n#### divS(number)\nDivide this vector by a number.\n\n#### dot(vector)\nReturns dot product from this vector and the provided vector.\n\n#### cross(vector)\nReturns cross product from this vector and the provided vector.\n\n#### reverse()\nReverse the values in this vector.\n\n#### abs()\nConvert stored values to absolute values.\n\n#### distance(vec)\nFind the distance between this vector and the provided _vec_;\n\n#### zero()\nSet vector values to 0.\n\n#### rotate(radians)\nRotate vector by provided radians.\n\n#### clone()\nReturns a clone of this vector.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanshortiss%2Fvector2d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevanshortiss%2Fvector2d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevanshortiss%2Fvector2d/lists"}