summaryrefslogtreecommitdiff
path: root/frontend/_shared/math/line2.js
diff options
context:
space:
mode:
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);