{"id":16266480,"url":"https://github.com/thormeier/vanilla-vectors-3d","last_synced_at":"2025-03-19T23:30:43.065Z","repository":{"id":57390718,"uuid":"118361068","full_name":"thormeier/vanilla-vectors-3d","owner":"thormeier","description":"JS library for basic vector calculations in a 3D space","archived":false,"fork":false,"pushed_at":"2018-04-08T12:54:09.000Z","size":10,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-17T11:55:01.290Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/thormeier.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}},"created_at":"2018-01-21T18:18:50.000Z","updated_at":"2024-03-28T08:32:54.000Z","dependencies_parsed_at":"2022-09-06T21:10:09.306Z","dependency_job_id":null,"html_url":"https://github.com/thormeier/vanilla-vectors-3d","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/thormeier%2Fvanilla-vectors-3d","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fvanilla-vectors-3d/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fvanilla-vectors-3d/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thormeier%2Fvanilla-vectors-3d/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thormeier","download_url":"https://codeload.github.com/thormeier/vanilla-vectors-3d/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244524552,"owners_count":20466450,"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-10-10T17:42:08.065Z","updated_at":"2025-03-19T23:30:42.775Z","avatar_url":"https://github.com/thormeier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Vanilla Vectors 3D\n\n[![Build Status](https://travis-ci.org/thormeier/vanilla-vectors-3d.svg?branch=master)](https://travis-ci.org/thormeier/vanilla-vectors-3d)\n\nA small library with vectors, lines and planes that allows for some simple vector geometry calculations. Written in plain vanilla JS, hence the name.\n\n## Installation\n\n    npm install --save vanilla-vectors-3d\n\n## Usage (ES6)\n\nCreate a vector with `P(1/2/3)`:\n\n    import { Vector, Line, Plane } from 'vanilla-vectors-3d'\n    \n    const v = new Vector(1, 2, 3)\n    \nDo some calculations:\n\n    const v1 = new Vector(1, 2, 3)\n    const v2 = new Vector(4, 5, 6)\n    \n    // Subtract\n    v1.minus(v2) // === Vector(-3, -3, -3)\n    \n    // Add\n    v1.plus(v2) // === Vector(5, 7, 9)\n    \n    // Multiply with a scalar\n    v1.timesScalar(3) // === Vector(3, 6, 9)\n    \n    // Cross product of two vectors\n    v1.cross(v2) // === Vector(-3, 6, -3)\n    \n    // Scalar product of two vectors\n    v1.scalarProduct(v2) // === -24\n    \n    // Length\n    v1.length // === 3.741...\n    \n    // Transform vector to a length of 1\n    v1.normalize() // === Vector(0.26..., 0.53..., 0.80...)\n    \n    // Rotate around an axis\n    const v3 = new Vector(1, 0, 0)\n    v3.rotate('y', 90) // === Vector(0, 0, -1)\n    \n    // Rotate around a line represented by its normal vector\n    v3.rotateAroundVector(v1.normalize(), 90)\n    \n    // Rotate around Line object\n    v3.rotateAroundLine(new Line(v1, v2), 90)\n    \n    // Check if one vector is a multiple of another\n    v1.isLinearlyDependentOn(v2) // === false\n    \n    // Check if two vectors are equal\n    v1.isEqualTo(v2)\n    \n    // Apply a transformation matrix\n    v1.applyTransformationMatrix([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) //  === v1\n\nAlso lines are given:\n\n    const v1 = new Vector(1, 1, 1)\n    const v2 = new Vector(2, 2, 2)\n    \n    const l = new Line(v1, v2)\n    \n    // Rotate line around two axes X and Z\n    l.rotate(180, 180)\n    \n    // Rotate line around another line\n    const v3 = new Vector(4, 5, 6)\n    const v4 = new Vector(7, 8, 9)\n    \n    l.rotateAroundLine(new Line(v3, v4), 90)\n    \nAs well as planes:\n\n    const v1 = new Vector(0, 0, 0)\n    const v2 = new Vector(1, 0, 0)\n    const v3 = new Vector(0, 1, 0)\n    \n    const p = new Plane(v1, v2, v3)\n    \n    // Calculate an intersection vector with a given line\n    const v4 = new Vector(1, 1, 1)\n    const v5 = new Vector(1, 1, -1)\n    const l = new Line(v4, v5)\n    \n    p.getIntersectionWith(l) // Vector if one point exists, null if Line is within Plane or parallel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthormeier%2Fvanilla-vectors-3d","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthormeier%2Fvanilla-vectors-3d","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthormeier%2Fvanilla-vectors-3d/lists"}