diff options
| author | Matthew Kosarek <matthew.kosarek@vention.cc> | 2021-02-27 17:32:32 -0500 |
|---|---|---|
| committer | Matthew Kosarek <matthew.kosarek@vention.cc> | 2021-02-27 17:32:32 -0500 |
| commit | d1b528b01796601c2bfea7b1a9813e5907e1c728 (patch) | |
| tree | 77e2200e930fcad2166edf1e3d31d4cd1211db56 /frontend/_shared/math/line2.js | |
| parent | 026abdb98ad30209df0e88795f25b1f74556585e (diff) | |
Close to being done on line-circle collisions, but it appears we're running into a rotation problem. Going to work on square-line collisions in the meantime
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); |
