summaryrefslogtreecommitdiff
path: root/frontend/_shared/math/vec2.js
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-05-16 19:50:15 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-05-16 19:50:15 -0400
commita00c0aab1eb5a7a55bef8ca08115bdd722ab5699 (patch)
tree45b5c4cc8c380d0630a8e0185af7229f26dc754a /frontend/_shared/math/vec2.js
parent4941a1874b6ca9d142d94df70b2aec5e0b35b94e (diff)
Moved the frontend directory up so that it no longer exists
Diffstat (limited to 'frontend/_shared/math/vec2.js')
-rw-r--r--frontend/_shared/math/vec2.js64
1 files changed, 0 insertions, 64 deletions
diff --git a/frontend/_shared/math/vec2.js b/frontend/_shared/math/vec2.js
deleted file mode 100644
index 11e71cd..0000000
--- a/frontend/_shared/math/vec2.js
+++ /dev/null
@@ -1,64 +0,0 @@
-function vec2(x = 0, y = 0) {
- return { x: x, y: y};
-}
-
-function addVec2(v1, v2) {
- return {
- x: v1.x + v2.x,
- y: v1.y + v2.y
- };
-}
-
-function subVec2(v1, v2) {
- return {
- x: v1.x - v2.x,
- y: v1.y - v2.y
- };
-}
-
-function scaleVec2(v, s) {
- return {
- x: v.x * s,
- y: v.y * s
- };
-}
-
-function dot2(v1, v2) {
- return v1.x * v2.x + v1.y * v2.y;
-}
-
-function length2(v) {
- return Math.sqrt(v.x * v.x + v.y * v.y);
-}
-
-function normalize2(v) {
- const lLength = length2(v);
- const lInverseLength = lLength === 0 ? 1.0 : 1.0 / length2(v);
- return { x: v.x * lInverseLength, y: v.y * lInverseLength };
-}
-
-function vec2str(v) {
- return `(${v.x.toFixed(2)}, ${v.y.toFixed(2)})`;
-}
-
-function getPerp2(v) {
- return {
- x: -v.y,
- y: v.x
- };
-}
-
-function negate2(v) {
- return {
- x: -v.x,
- y: -v.y
- };
-}
-
-// Algorithm plucked from: https://matthew-brett.github.io/teaching/rotation_2d.html
-function rotateAboutOrigin2(v, angle) {
- return {
- x: v.x * Math.cos(angle) - v.y * Math.sin(angle),
- y: v.x * Math.sin(angle) + v.y * Math.cos(angle),
- };
-} \ No newline at end of file