Add
This commit is contained in:
commit
18b158f54f
3
javascript/ultra32/.gitignore
vendored
Normal file
3
javascript/ultra32/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
node_modules
|
||||
app.ts
|
||||
tsconfig.json
|
21
javascript/ultra32/LICENSE
Normal file
21
javascript/ultra32/LICENSE
Normal file
|
@ -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.
|
26
javascript/ultra32/README.md
Normal file
26
javascript/ultra32/README.md
Normal file
|
@ -0,0 +1,26 @@
|
|||
# 🚧 This repo has been moved to [prescientmoon/ultra32](https://github.com/prescientmoon/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 ]
|
||||
```
|
51
javascript/ultra32/app.js
Normal file
51
javascript/ultra32/app.js
Normal file
|
@ -0,0 +1,51 @@
|
|||
"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;
|
||||
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;
|
||||
function clone(vector) {
|
||||
const newVec = new Float32Array(vector.length);
|
||||
for (let i = 0; i < vector.length; i++) {
|
||||
newVec[i] = vector[i];
|
||||
}
|
||||
return newVec;
|
||||
}
|
5
javascript/ultra32/package-lock.json
generated
Normal file
5
javascript/ultra32/package-lock.json
generated
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"name": "ultra32",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
}
|
22
javascript/ultra32/package.json
Normal file
22
javascript/ultra32/package.json
Normal file
|
@ -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": {}
|
||||
}
|
Loading…
Reference in a new issue