{"id":27160318,"url":"https://github.com/spikeburton/vector-js","last_synced_at":"2025-04-08T23:41:19.392Z","repository":{"id":35063383,"uuid":"167287829","full_name":"spikeburton/vector-js","owner":"spikeburton","description":"⚙️ An open source implementation of mathematical vectors in JavaScript","archived":false,"fork":false,"pushed_at":"2023-01-04T08:46:42.000Z","size":898,"stargazers_count":3,"open_issues_count":14,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-07T12:05:19.430Z","etag":null,"topics":["javascript","mathematical-vectors","vector","vector-space"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@glazier/vector-js","language":"JavaScript","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/spikeburton.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-24T02:20:46.000Z","updated_at":"2022-02-02T19:35:02.000Z","dependencies_parsed_at":"2023-01-15T13:02:50.269Z","dependency_job_id":null,"html_url":"https://github.com/spikeburton/vector-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spikeburton%2Fvector-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spikeburton%2Fvector-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spikeburton%2Fvector-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spikeburton%2Fvector-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spikeburton","download_url":"https://codeload.github.com/spikeburton/vector-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247947823,"owners_count":21023058,"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":["javascript","mathematical-vectors","vector","vector-space"],"created_at":"2025-04-08T23:41:18.652Z","updated_at":"2025-04-08T23:41:19.387Z","avatar_url":"https://github.com/spikeburton.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VectorJS\n\n[![Build Status](https://travis-ci.org/spikeburton/vector-js.svg?branch=master)](https://travis-ci.org/spikeburton/vector-js)\n[![npm (scoped)](https://img.shields.io/npm/v/@glazier/vector-js)](https://www.npmjs.com/package/@glazier/vector-js)\n[![GitHub](https://img.shields.io/github/license/spikeburton/vector-js?color=blue)](https://github.com/spikeburton/vector-js/blob/master/LICENSE.md)\n[![GitHub issues](https://img.shields.io/github/issues/spikeburton/vector-js)](https://github.com/spikeburton/vector-js/issues)\n[![GitHub closed issues](https://img.shields.io/github/issues-closed/spikeburton/vector-js)](https://github.com/spikeburton/vector-js/issues?q=is%3Aissue+is%3Aclosed)\n\nAn implementation of mathematical vectors in JavaScript. The vector space is n-dimensional, with support for cross product and tension vectors.\n\nA vector is defined here as a set of ordered coordinates in the vector space of cardinality **n** which has both magnitude and direction. VectorJS implements functionality to represent a vector as a 1-dimensional array containing **n** elements as input for each method.\n\n## Install\n\n```sh\nnpm i @glazier/vector-js\n```\n\n## Usage\n\n```js\nconst { Vector, TensionVector } = require('@glazier/vector-js');\n\nconst v1 = new Vector(1, 2, 3);\nconst v2 = new Vector(2, 4, 6);\n\n// Adding two vectors\n// OUTPUT: (3, 6, 9)\nconsole.log(v1.add(v2).toString());\n\n// Using an array of coordinates\n// OUTPUT: (3, 6, 9)\nconsole.log(v1.add([2, 4, 6]).toString());\n\n// Scalar multiplication\n// OUTPUT: (4, 8, 12)\nconsole.log(v1.mul(4).toString());\n\n// Dot product\n// OUTPUT: 28\nconsole.log(v1.dot(v2).toString());\n\n// Cross product\n// OUTPUT: (0, 0, 0)\nconsole.log(v1.cross(v2).toString());\n\n// Unit vector\n// NOTE: Normalization is non-destructive and returns a new Vector object\n// OUTPUT: (0.2672612419124244, 0.1336306209562122, 0.0890870806374748)\nconsole.log(v1.normalize().toString());\n\n// Vector magnitude\n// OUTPUT: 3.7416573867739413\nconsole.log(v1.length)\n\n// OUTPUT: [ 1, 2, 3 ]\nconsole.log(v1.coords);\n\n// Convert to an array\n// OUTPUT: [ 1, 2, 3 ]\nconsole.log(v1.toArray());\n\n// OUTPUT: [ 1, 2, 13 ]\nv1.setAxis(2, 13);\nconsole.log(v1.coords);\n\n// OUTPUT: 13\nconsole.log(v1.getAxis(2));\n```\n\n## Release Notes\n\n- 1.2.0:\n  - New and improved algorithms for vector operations designed to be more efficient\n  - Addition of `combine` and `scale` methods which are designed to be flexible by taking a callback to operate on a vector\n  - Improved error handling for all operations\n  - Improved checking to ensure scalars must be finite and non-empty\n- 1.1.1:\n  - Improved documentation\n  - Added Travis CI and Jest for testing\n  - Refactored iterators in vector operations to not use reduce\n\n## 🚧🚧🚧\n### TODO:\n\n- Add Babel for backwards compatibility\n- Add Rollup for build minification\n- Add ESLint integration\n- Improve documentation and add examples","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspikeburton%2Fvector-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspikeburton%2Fvector-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspikeburton%2Fvector-js/lists"}