From 5b7701af958d509fd33253147bed9b853b4abad9 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 18:18:35 +0200 Subject: [PATCH 1/5] javascript(ultra32): Initial commit Signed-off-by: prescientmoon --- javascript/ultra32/.gitignore | 61 +++++++++++++++++++++++++++++++++++ javascript/ultra32/LICENSE | 21 ++++++++++++ javascript/ultra32/README.md | 2 ++ 3 files changed, 84 insertions(+) create mode 100644 javascript/ultra32/.gitignore create mode 100644 javascript/ultra32/LICENSE create mode 100644 javascript/ultra32/README.md diff --git a/javascript/ultra32/.gitignore b/javascript/ultra32/.gitignore new file mode 100644 index 0000000..ad46b30 --- /dev/null +++ b/javascript/ultra32/.gitignore @@ -0,0 +1,61 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next diff --git a/javascript/ultra32/LICENSE b/javascript/ultra32/LICENSE new file mode 100644 index 0000000..20a90a1 --- /dev/null +++ b/javascript/ultra32/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Matei Adriel + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/javascript/ultra32/README.md b/javascript/ultra32/README.md new file mode 100644 index 0000000..1f62d23 --- /dev/null +++ b/javascript/ultra32/README.md @@ -0,0 +1,2 @@ +# ultra32 +A vector package using the fast float32array From edd15321fa32ffa1569591beea0203b2ebaae659 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 20:27:57 +0200 Subject: [PATCH 2/5] javascript(ultra32): added basic functions Signed-off-by: prescientmoon --- javascript/ultra32/README.md | 25 ++++++++++++++++++- javascript/ultra32/app.js | 37 ++++++++++++++++++++++++++++ javascript/ultra32/package-lock.json | 5 ++++ javascript/ultra32/package.json | 22 +++++++++++++++++ 4 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 javascript/ultra32/app.js create mode 100644 javascript/ultra32/package-lock.json create mode 100644 javascript/ultra32/package.json diff --git a/javascript/ultra32/README.md b/javascript/ultra32/README.md index 1f62d23..f590071 100644 --- a/javascript/ultra32/README.md +++ b/javascript/ultra32/README.md @@ -1,2 +1,25 @@ -# ultra32 +# Ultra32 A vector package using the fast float32array + + +# Get started: + +To get started, install ultra32: +``` +npm install ultra32 --save +``` + +A ultra32 vector is just a Float32Array. + +``` +const vec = new Float32Array([0,0]); +``` + +You can perform multiple operations: +``` +add(vec,new Float32Array([1,2])); +mul(vec,3); +mirror(vec); + +console.log(vec); //Float32Array [ -3, -6 ] +``` diff --git a/javascript/ultra32/app.js b/javascript/ultra32/app.js new file mode 100644 index 0000000..d0e2546 --- /dev/null +++ b/javascript/ultra32/app.js @@ -0,0 +1,37 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +function add(vector, other) { + for (let i = 0; i < vector.length; i++) { + vector[i] = vector[i] + other[i]; + } + return vector; +} +exports.add = add; +function sub(vector, other) { + for (let i = 0; i < vector.length; i++) { + vector[i] = vector[i] - other[i]; + } + return vector; +} +exports.sub = sub; +function div(vector, scalar) { + for (let i = 0; i < vector.length; i++) { + vector[i] /= scalar; + } + return vector; +} +exports.div = div; +function mul(vector, scalar) { + for (let i = 0; i < vector.length; i++) { + vector[i] *= scalar; + } + return vector; +} +exports.mul = mul; +function mirror(vector) { + for (let i = 0; i < vector.length; i++) { + vector[i] = -vector[i]; + } + return vector; +} +exports.mirror = mirror; diff --git a/javascript/ultra32/package-lock.json b/javascript/ultra32/package-lock.json new file mode 100644 index 0000000..36f26fd --- /dev/null +++ b/javascript/ultra32/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "ultra32", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/javascript/ultra32/package.json b/javascript/ultra32/package.json new file mode 100644 index 0000000..b9e1c7d --- /dev/null +++ b/javascript/ultra32/package.json @@ -0,0 +1,22 @@ +{ + "name": "ultra32", + "version": "1.0.0", + "description": "A vector package using the fast float32array", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "github", + "url": "https://github.com/Mateiadrielrafael/ultra32" + }, + "keywords": [ + "vector", + "float32array", + "webgl" + ], + "author": "Matei Adriel", + "license": "ISC", + "dependencies": {}, + "devDependencies": {} +} From 2ecbd6d4b41dcd8e3615338c9d961e841abed1b5 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 14:36:47 +0200 Subject: [PATCH 3/5] javascript(ultra32): added rotate Signed-off-by: prescientmoon --- javascript/ultra32/.gitignore | 64 ++--------------------------------- javascript/ultra32/app.js | 7 ++++ 2 files changed, 10 insertions(+), 61 deletions(-) diff --git a/javascript/ultra32/.gitignore b/javascript/ultra32/.gitignore index ad46b30..16fdf4d 100644 --- a/javascript/ultra32/.gitignore +++ b/javascript/ultra32/.gitignore @@ -1,61 +1,3 @@ -# Logs -logs -*.log -npm-debug.log* -yarn-debug.log* -yarn-error.log* - -# Runtime data -pids -*.pid -*.seed -*.pid.lock - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# nyc test coverage -.nyc_output - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Bower dependency directory (https://bower.io/) -bower_components - -# node-waf configuration -.lock-wscript - -# Compiled binary addons (https://nodejs.org/api/addons.html) -build/Release - -# Dependency directories -node_modules/ -jspm_packages/ - -# TypeScript v1 declaration files -typings/ - -# Optional npm cache directory -.npm - -# Optional eslint cache -.eslintcache - -# Optional REPL history -.node_repl_history - -# Output of 'npm pack' -*.tgz - -# Yarn Integrity file -.yarn-integrity - -# dotenv environment variables file -.env - -# next.js build output -.next +node_modules +app.ts +tsconfig.json diff --git a/javascript/ultra32/app.js b/javascript/ultra32/app.js index d0e2546..b9849ea 100644 --- a/javascript/ultra32/app.js +++ b/javascript/ultra32/app.js @@ -35,3 +35,10 @@ function mirror(vector) { return vector; } exports.mirror = mirror; +function rotate(vector) { + const oldx = vector[0]; + vector[0] = Math.cos(vector[0]) - Math.sin(vector[1]); + vector[1] = Math.sin(oldx) + Math.cos(vector[1]); + return vector; +} +exports.rotate = rotate; From 676e541926c8f77c3533a3e008193ef656374eb6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 14:39:46 +0200 Subject: [PATCH 4/5] javascript(ultra32): clone Signed-off-by: prescientmoon --- javascript/ultra32/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/javascript/ultra32/app.js b/javascript/ultra32/app.js index b9849ea..e7dad04 100644 --- a/javascript/ultra32/app.js +++ b/javascript/ultra32/app.js @@ -42,3 +42,10 @@ function rotate(vector) { return vector; } exports.rotate = rotate; +function clone(vector) { + const newVec = new Float32Array(vector.length); + for (let i = 0; i < vector.length; i++) { + newVec[i] = vector[i]; + } + return newVec; +} From 5344cb996db3004744c9a7f55765c4ebfbd739fb Mon Sep 17 00:00:00 2001 From: prescientmoon Date: Tue, 28 May 2024 01:55:09 +0200 Subject: [PATCH 5/5] javascript(ultra32): Added movement notice to readme [skip-ci] Signed-off-by: prescientmoon --- javascript/ultra32/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/javascript/ultra32/README.md b/javascript/ultra32/README.md index f590071..9d22e89 100644 --- a/javascript/ultra32/README.md +++ b/javascript/ultra32/README.md @@ -1,3 +1,4 @@ +# 🚧 This repo has been moved to [prescientmoon/ultra32](https://github.com/prescientmoon/ultra32) 🚧 # Ultra32 A vector package using the fast float32array