{"id":21493534,"url":"https://github.com/alienkevin/vector-js","last_synced_at":"2025-03-17T11:41:47.222Z","repository":{"id":51552135,"uuid":"225917024","full_name":"AlienKevin/vector-js","owner":"AlienKevin","description":"1 to 3 dimensional vector calculation in JavaScript","archived":false,"fork":false,"pushed_at":"2023-01-05T02:19:29.000Z","size":1403,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-23T21:24:36.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/AlienKevin.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":"2019-12-04T17:04:20.000Z","updated_at":"2019-12-05T17:09:45.000Z","dependencies_parsed_at":"2023-02-03T05:45:59.991Z","dependency_job_id":null,"html_url":"https://github.com/AlienKevin/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/AlienKevin%2Fvector-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienKevin%2Fvector-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienKevin%2Fvector-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlienKevin%2Fvector-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlienKevin","download_url":"https://codeload.github.com/AlienKevin/vector-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244029497,"owners_count":20386419,"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":[],"created_at":"2024-11-23T15:43:17.091Z","updated_at":"2025-03-17T11:41:47.195Z","avatar_url":"https://github.com/AlienKevin.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vector-js\nSimple 1d-3d vector library supporting angular and component forms.\n\n# Vector types\nA vector can be in either two forms - component or angular.\n\n## Component Vector (VectorCom)\nVector is stored as a list of numbers.\n### 1d Vector\n```ts\n[number]\n```\n![1d vector in component form](medias/1d_vector_com.png)\n\n### 2d Vector\n```ts\n[number, number]\n```\n![2d vector in component form](medias/2d_vector_com.png)\n\n### 3d Vector\n```ts\n[number, number, number]\n```\n![3d vector in component form slant view](medias/3d_vector_com_1.png)\n\nTop View\n\n![3d vector in component form top view](medias/3d_vector_com_top.png)\n\nSide View\n\n![3d vector in component form side view](medias/3d_vector_com_side.png)\n\n## Angular Vector (VectorAng)\nVector is stored as an object with three properties:\n- `mag` for magnitude\n- `dir` for direction\n- `dim` for dimension\n\n### 1d Vector\n```ts\n{\n    mag: number, // mag \u003e= 0\n    dir: -1 | 1, // -1 for negative and 1 for positive direction\n    dim: 1\n}\n```\n![1d vector in angular form](medias/1d_vector_ang.png)\n\n### 2d Vector\n```ts\n{\n    mag: number, // mag \u003e= 0\n    dir: number, // angle in degrees within (-180, 180]\n    dim: 2\n}\n```\n![2d vector in angular form](medias/2d_vector_ang.png)\n\n### 3d Vector\n```ts\n{\n    mag: number, // mag \u003e= 0\n    dir: [number, number], // two angles in degrees within (-180, 180]\n    dim: 3\n}\n```\n\nFirst angle α of `dir` is on the x-y horizontal plane. It's the angle of the vector's projection onto the x-y plane. Second angle β of `dir` is along the z axis. It's the angle between the vector and its projection onto the x-y plane.\n\n![3d vector in angular form slant view](medias/3d_vector_ang_1.png)\n\nTop View\n\n![3d vector in angular form top view](medias/3d_vector_ang_top.png)\n\nSide View\n\n![3d vector in angular form side view](medias/3d_vector_ang_side.png)\n\n# Vector Operations\n\nTo indicate which form to produce the resultant vector, use `VectorForm` flag which can be either `\"com\"` for component or `\"ang\"` for angular. Form defaults to `\"com\"` for component vectors.\n\n## decomposeVector(v: Vector): VectorCom\nBreak a vector into its components.\n\n## angularizeVector(v: Vector): VectorAng\nConvert a vector into its angular form - magnitude and direction.\n\n## addVectors(vs: Vector[], form: VectorForm): Vector\nAdd two vectors in the same dimension to produce a resultant vector in `form` (`\"ang\"` or `\"com\"`).\n\n## negateVector(v: Vector, form: VectorForm): Vector\nNegate a vector's direction to produce a resultant vector in `form`.\n\n## subtractVectors(v1: Vector, v2: Vector, form: VectorForm): Vector\nSubtract v2 from v1 (v1 - v2) to produce a resultant vector in `form`. v1 and v2 must be in the same dimension.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienkevin%2Fvector-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falienkevin%2Fvector-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falienkevin%2Fvector-js/lists"}