summaryrefslogtreecommitdiff
path: root/frontend/_shared/math/line2.js
diff options
context:
space:
mode:
authorMatthew Kosarek <matthew.kosarek@vention.cc>2021-03-02 20:03:02 -0500
committerMatthew Kosarek <matthew.kosarek@vention.cc>2021-03-02 20:03:02 -0500
commita315509189073cdaf4172bcfd4e4a54e5c8c87eb (patch)
tree2fc57ae4c86d430a3478e012ae10bacee0b7ba41 /frontend/_shared/math/line2.js
parentd1b528b01796601c2bfea7b1a9813e5907e1c728 (diff)
Updated stylings and very nearly have square collisions complete and proper
Diffstat (limited to 'frontend/_shared/math/line2.js')
-rw-r--r--frontend/_shared/math/line2.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/frontend/_shared/math/line2.js b/frontend/_shared/math/line2.js
index a9e72be..8b30c1c 100644
--- a/frontend/_shared/math/line2.js
+++ b/frontend/_shared/math/line2.js
@@ -32,7 +32,8 @@ function line2(pStart, pEnd, pGl, pColor, pMass) {
length: length2(lDiffVector),
mass: pMass,
direction: normalize2(lDiffVector),
- velocity: vec2(0, 0)
+ velocity: vec2(0, 0),
+ position: vec2()
};
}
@@ -40,6 +41,13 @@ function getLine2MomentOfInertia(pLine) {
return (1.0 / 12.0) * pLine.mass * Math.pow(pLine.length, 2);
}
+function getLine2MidPoint(pLine) {
+ return {
+ x: (pLine.end.x + pLine.start.x) / 2.0,
+ y: (pLine.end.y + pLine.start.y) / 2.0
+ }
+}
+
function renderLine2(pGl, pProgramInfo, pLine) {
pGl.uniformMatrix4fv(pProgramInfo.uniformLocations.model, false, mat4()); // Model on a line is always default matrix
pGl.bindBuffer(pGl.ARRAY_BUFFER, pLine.buffer);