{"id":26449551,"url":"https://github.com/alireza29675/d0","last_synced_at":"2025-03-18T14:58:15.931Z","repository":{"id":57211312,"uuid":"94914135","full_name":"Alireza29675/d0","owner":"Alireza29675","description":"Dimension 0 in n-Dimensions World","archived":false,"fork":false,"pushed_at":"2017-09-17T21:23:36.000Z","size":63,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-14T23:10:40.280Z","etag":null,"topics":["dimensions","math","point"],"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/Alireza29675.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":"2017-06-20T16:47:24.000Z","updated_at":"2019-05-24T17:48:04.000Z","dependencies_parsed_at":"2022-08-30T12:30:17.470Z","dependency_job_id":null,"html_url":"https://github.com/Alireza29675/d0","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/Alireza29675%2Fd0","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fd0/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fd0/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Alireza29675%2Fd0/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Alireza29675","download_url":"https://codeload.github.com/Alireza29675/d0/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244246509,"owners_count":20422456,"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":["dimensions","math","point"],"created_at":"2025-03-18T14:58:15.424Z","updated_at":"2025-03-18T14:58:15.923Z","avatar_url":"https://github.com/Alireza29675.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# d0\n\nDimension 0 in n-Dimensional World\n\n\n## Motivation\n\nThis package has created to use in fields that you need to use physics rules without any real world limitation and AI fields\n\n\n## Installation\n\nYou can install this package by the following ways :\n\n 1. Clone [this repository](https://github.com/Alireza29675/d0) directly from Github then get and use the main js file from `lib/`\n 2. Install package using [npm](https://npmjs.org) :\n ```bash\n npm install --save D0\n ```\n\n## Preparation for use \n\nAfter importing D0 to your code like this:\n```javascript\nimport D0 from 'd0'\n```\n\nYou can create a multi-dimensional point with desired dimensions\n\n```javascript\nlet point = new D0(3, 4, 5, 6, 7); // =\u003e x = 3, y = 4, z = 5, w = 6, dimension-5 = 7\n```\n\nAlso you can access to the origin point in your application using:\n```javascript\nD0.ZERO // =\u003e x = 0, y = 0, z = 0, ... [dimension-n = 0]\n```\n\n## Methods and Properties\n\n\n### D0.prototype.d(n, [setTo])\n\nWith this method you can either `get` or `set` the dimension-n value\n\n```javascript\nconsole.log(point.d(1)); // =\u003e 3\n// returns the value of dimension-1 (x)\npoint.d(4, 6.5);\n// sets the dimension-4's value to 6.5\n```\n\n---\n\n### D0.prototype.count\n\nreturns count of point's dimensions\n\n```javascript\nconsole.log(point.count); // =\u003e 5\n```\n\n---\n\n### D0.prototype.x, D0.prototype.y, D0.prototype.z, D0.prototype.w\n\nD0 has `getters` for most useful dimensions:\n\n```javascript\nconsole.log(point.x); // =\u003e 3\nconsole.log(point.y); // =\u003e 4\nconsole.log(point.z); // =\u003e 5\nconsole.log(point.w); // =\u003e 6.5\n```\n\nAlso there are `setters` for them which you can use like:\n\n```javascript\npoint.z = 8;\nconsole.log(point.z); // =\u003e 8\n```\n\n---\n\n### D0.prototype.each(callback)\n\nExecutes a provided function once for each dimension.\n\n**Syntax:**\n```javascript\nD0.prototype.each(function callback(dimensionIndex, dimensionValue) {\n    // your iterator\n});\n```\n\n**Example:**\n```javascript\npoint.each(function(index, value){\n    console.log(`#${index} ~\u003e ${value}`);\n})\n// logs\n// #1 ~\u003e 3\n// #2 ~\u003e 4\n// #3 ~\u003e 8\n// #4 ~\u003e 6.5\n// #5 ~\u003e 7\n```\n\n---\n\n### D0.prototype.eachWith(secondPoint, callback)\n\nExecutes a provided function one by one for each dimension of two points.\n\n**Syntax:**\n```javascript\nD0.prototype.eachWith(secondPoint, function callback(dimensionIndex, dimensionValueOfPoint1, dimensionValueOfPoint2) {\n    // your iterator\n});\n```\n\n**Example:**\n```javascript\nlet point2 = new D0(10, 4, 5)\npoint.eachWith(point2, function(index, valueOfPoint1, valueOfPoint2){\n    console.log(`${valueOfPoint1}, ${valueOfPoint2}, ${valueOfPoint1 === valueOfPoint2}`);\n})\n// logs\n// 3, 10, false\n// 4, 4, true\n// 8, 5, false\n// 6.5, 0, false\n// 7, 0, false\n```\n\n---\n\n### D0.prototype.add({D0})\n\nAdd two points.\n\n**Example:**\n```javascript\npoint.add({D0})\nconsole.log(point.toString()) // =\u003e (13, 8, 13, 6.5, 7)\n```\n\n---\n\n\n### D0.prototype.midPoint({D0})\n\nCalculate average of points.\n\n**Example:**\n```javascript\npoint.midPoint({D0})\nconsole.log(point.midPoint(point2).toString()) \n// =\u003e (6.5, 4, 6.5, 3.25, 3.5)\n```\n\n---\n\n\n### D0.prototype.subtract({D0})\n\nSubtract two Points\n\n**Example:**\n```javascript\npoint.subtract({D0})\nconsole.log(point.toString()) // =\u003e (-3, 0, 3, 6.5, 7)\n```\n\n---\n\n### D0.prototype.multiply({D0|Number})\n\nMutiply two Points or a point to a number.\n\n**Syntax:**\n```javascript\nD0.prototype.mutiply({D0|Number})\n```\n\n**Example with {D0}:**\n```javascript\nconsole.log(point.toSting()) // =\u003e (-3, 0, 3, 6.5, 7)\nconsole.log(point2.toSting()) // =\u003e (10, 4, 5, 0, 0)\npoint.mutiply(point2)\nconsole.log(point.toString()) // =\u003e (-30, 0, 15, 0, 0)\n```\n\n**Example with {Number}:**\n```javascript\nconsole.log(point.toString())\n// =\u003e (-3, 0, 3, 6.5, 7)\npoint.mutiply(2)\nconsole.log(point.toString())\n// =\u003e (-6, 0, 6, 13, 14)\n```\n\n---\n\n### D0.prototype.divide({D0|Number})\n\nDivide the point by anthor point or a number\n\n**Syntax:**\n```javascript\nD0.prototype.divide({D0|Number})\n```\n\n**Example with {D0}:**\n```javascript\nconsole.log(point.toSting()) // =\u003e (-30, 0, 15, 0, 0)\nconsole.log(point2.toSting()) // =\u003e (10, 4, 5, 0, 0)\npoint.divide(point2)\nconsole.log(point.toString()) // =\u003e (-3, 0, 3, 6.5, 7)\n```\n\n**Example with {Number}:**\n```javascript\nconsole.log(point.toString())\n// =\u003e (-6, 0, 6, 13, 14)\npoint.divide(3)\nconsole.log(point.toString())\n// =\u003e (-2, 0, 2, 4.3, 4.6)\n```\n\n---\n\n### D0.prototype.equals({D0})\n\nCompare two points.\n\n**Example:**\n```javascript\nconsole.log(point.equals(point2)) // =\u003e false\n```\n\n---\n\n### D0.prototype.abs()\n\nThis method return absolute value of every dimensions.\n\n**Example:**\n```javascript\npoint.d(1, -60)\nconsole.log(point.abs().toString()) // =\u003e (60, 32, 80, 0, 0)\n```\n\n---\n\n### D0.prototype.distanceToOrigin()\n\nCalculate euclidean distance between this point and the origin.\n\n**Syntax:**\n```javascript\nD0.prototype.distanceToOrigin()\n```\n\n**Example:**\n```javascript\nconsole.log(point.distanceToOrigin())\n// log =\u003e 104.9952379872535\n```\n\n---\n\n### D0.prototype.euclideanDistanceTo({D0})\n\nCalculate euclidean distance between two points.\n\n**Syntax:**\n```javascript\nD0.prototype.euclideanDistanceTo({D0})\n```\n\n**Example:**\n```javascript\nconsole.log(point.euclideanDistanceTo(point2))\n// log =\u003e 94.38749917229505\n```\n\n---\n\n### D0.prototype.manhattanDistanceTo({D0})\n\nCalculate manhattan distance between two points.\n\n**Syntax:**\n```javascript\nD0.prototype.manhattanDistanceTo({D0})\n```\n\n**Example:**\n```javascript\nconsole.log(point.manhattanDistanceTo(point)) // log =\u003e 153\n```\n\n---\n\n### D0.prototype.manhattanDistanceTo({D0})\n\nCalculate square distance between two points.\n\n**Syntax:**\n```javascript\nD0.prototype.squareDistanceTo({D0})\n```\n\n**Example:**\n```javascript\nconsole.log(point.squareDistanceTo(point)) // log =\u003e 75\n```\n\n---\n\n### D0.prototype.distanceTo({D0})\n\nReturns euclidean distance between two points.\n\n**Syntax:**\n```javascript\nD0.prototype.distanceTo({D0})\n```\n\n**Example:**\n```javascript\nconsole.log(point.distanceTo(point))\n// log =\u003e 94.38749917229505\n```\n\n---\n\n### D0.prototype.clone()\n\nSimply create a copy of the point.\n\n```javascript\nconsole.log(point.toString()) // =\u003e (60, 32, 80)\nlet pointCopy = point.clone()\nconsole.log(pointCopy.toString()) // =\u003e (60, 32, 80)\nconsole.log(pointCopy === point) // =\u003e false\nconsole.log(pointCopy.equals(point)) // =\u003e true\n```\n\n---\n\n### D0.prototype.toString()\n\nConverts point to string\n\n```javascript\nconsole.log(point.toString()) // =\u003e (60, 32, 80)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falireza29675%2Fd0","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falireza29675%2Fd0","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falireza29675%2Fd0/lists"}