{"id":15414909,"url":"https://github.com/lxsmnsyc/vector","last_synced_at":"2025-03-28T03:17:50.658Z","repository":{"id":71067833,"uuid":"138307376","full_name":"lxsmnsyc/vector","owner":"lxsmnsyc","description":"Vector Math for ES6","archived":false,"fork":false,"pushed_at":"2018-07-27T15:19:23.000Z","size":638,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-02T04:25:43.414Z","etag":null,"topics":["es6","es6-javascript","es6-modules","javascript","math","mathematics","vector","vector-math","vectors"],"latest_commit_sha":null,"homepage":"","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/lxsmnsyc.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":"2018-06-22T13:41:54.000Z","updated_at":"2018-07-27T15:19:25.000Z","dependencies_parsed_at":"2023-02-21T23:46:35.350Z","dependency_job_id":null,"html_url":"https://github.com/lxsmnsyc/vector","commit_stats":{"total_commits":32,"total_committers":2,"mean_commits":16.0,"dds":0.0625,"last_synced_commit":"8d43a4e19bb4779a96d5e9077bf56fa411dfd414"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fvector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fvector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fvector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lxsmnsyc%2Fvector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lxsmnsyc","download_url":"https://codeload.github.com/lxsmnsyc/vector/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245960837,"owners_count":20700783,"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":["es6","es6-javascript","es6-modules","javascript","math","mathematics","vector","vector-math","vectors"],"created_at":"2024-10-01T17:05:14.111Z","updated_at":"2025-03-28T03:17:50.628Z","avatar_url":"https://github.com/lxsmnsyc.png","language":"JavaScript","readme":"# vector (in development)\nVector Math for ES6.\n### Table of Contents\n### Description\n### Installation\n### Usage\n#### Importing\n#### Example\n#### Overloading\n#### Chaining\nVector supports chaining on the following methods:\n```js\nlet v = new vec2(1, 2)\n        .assign(v2)\n        .negate()\n        .add(v2)\n        .sub(v2)\n        .mul(v2)\n        .div(v2)\n        .normalize()\n        .rotate(Math.PI)\n        .rotateOn(v2, Math.PI);\n```\n### API\n#### vec2\n##### The vec2 constructor has 4 overloads:\n```js\nlet v = new vec2(x, y); // x and y are coordinates\nlet v = new vec2(vector); // copies the passed vector's coordinates\nlet v = new vec2(value); // value is assigned to both x and y properties\nlet v = new vec2(); // creates a zero vector\n```\n##### vec2 getters\n```js\nv.isZero; // checks if the vector is a zero vector\nv.length2; // gets the squared magnitude/length of the vector.\nv.length; // gets the magnitude/length of the vector.\nv.angle; // gets the angle (in radians)\n```\n##### vec2 setters\n```js\nv.length = value; //sets the magnitude/length of the vector\nv.scale = factor; //scales(multiplies) the magnitude of the vector.\n```\n##### vec2 operations\n```js\nv.negate(); // negates (flips) a vector\nv.add(v2); // adds v2 to v\nv.add(value); // adds value to v (both x and y)\nv.sub(v2); // subtracts v2 to v\nv.sub(value); // subtracts value to v (both x and y)\nv.mul(v2); // multiplies v2 to v\nv.mul(value); // multiplies value to v\nv.div(v2); // divides v by v2\nv.div(value); // divides v by value\nv.dot(v2); // dot product of a vector\n```\n\n##### vec2 factory\nthe following methods produces a new vector\n```js\nv.mix(v2, t); // applies the mix (lerp) method. \nv.direction(); // gets the direction/unit vector. This is similar to the normalize method, but this extracts the unit vector.\nvec2.sum(v1, v2); // adds to vectors and produces a sum vector.\nvec2.sum(v1, value);\nvec2.sum(value, v2);\nvec2.diff(v1, v2); // difference vector\nvec2.diff(v1, value);\nvec2.diff(value, v2);\nvec2.prod(v1, v2); // product vector\nvec2.prod(v1, value);\nvec2.prod(value, v2);\nvec2.quot(v1, v2); // quotient vector\nvec2.quot(v1, value); // v1.x/value, v1.y/value\nvec2.quot(value, v2); // value/v2.x, value/v2.y\nv.clone(); // clones vector\n```\n##### other vec2 methods\n```js\nv.angleTo(v2); // the angle from a vector to another vector (in radians).\nv.directionTo(v2); // gets the direction vector (normalized difference) from v towards v2;\nv.distance2(v2); // squared distance between two vectors.\nv.distance(v2); // distance between two vectors.\nv.rotateOn(v, rad); // moves vector to another vector and rotates on that coordinates. rad can be radians or a direction vector.\nv.assign(v2); // assign v2's value to v\nv.equals(v2); // equality comparison of two vectors\nv.toArray(); // returns the Array representation of vector v\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxsmnsyc%2Fvector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flxsmnsyc%2Fvector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flxsmnsyc%2Fvector/lists"}