diff options
Diffstat (limited to 'frontend/_shared/math/line2.js')
-rw-r--r-- | frontend/_shared/math/line2.js | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/frontend/_shared/math/line2.js b/frontend/_shared/math/line2.js index d8ab096..a9e72be 100644 --- a/frontend/_shared/math/line2.js +++ b/frontend/_shared/math/line2.js @@ -7,7 +7,7 @@ * @param {vec2} pEnd * @param {WebGLRenderingContext} pGl */ -function line2(pStart, pEnd, pGl, pColor, pThickness) { +function line2(pStart, pEnd, pGl, pColor, pMass) { const lDiffVector = subVec2(pEnd, pStart); const lBuffer = pGl.createBuffer(); @@ -28,12 +28,18 @@ function line2(pStart, pEnd, pGl, pColor, pThickness) { start: pStart, end: pEnd, slope: lSlope, - angle: Math.atan(lSlope), + normal: normalize2(getPerp2(lDiffVector)), length: length2(lDiffVector), - direction: normalize2(lDiffVector) + mass: pMass, + direction: normalize2(lDiffVector), + velocity: vec2(0, 0) }; } +function getLine2MomentOfInertia(pLine) { + return (1.0 / 12.0) * pLine.mass * Math.pow(pLine.length, 2); +} + 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); |