Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <Catalin.Mititiuc@gmail.com>2024-03-21 16:19:49 -0700
committerCatalin Mititiuc <Catalin.Mititiuc@gmail.com>2024-03-21 16:19:49 -0700
commit2159804c11ff9a69ade3b45c1dde98a16626542f (patch)
treecb512af8598726d657234bf4a24f98cc4169d037 /index.js
parentdf548e8425a0c751eedb10ce96d66d74acc24e83 (diff)
WIP: firing arc cone
Diffstat (limited to 'index.js')
-rw-r--r--index.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/index.js b/index.js
index c56f66f..3b00a5c 100644
--- a/index.js
+++ b/index.js
@@ -37,8 +37,6 @@ rect.addEventListener('mousemove', e => {
let aim = document.querySelector('.firing-arc.active');
let p = document.querySelector('polyline.firing-arc.active');
- console.log(p);
-
// TODO: handle horizontal and vertical lines
if (aim || p) {
@@ -100,7 +98,23 @@ rect.addEventListener('mousemove', e => {
}
}
- p.setAttributeNS(null, 'points', `${newX},${newY} ${x1px},${y1px} ${newX},${newY}`);
+
+ let slope = (y2px - y1px) / (x2px - x1px);
+ let inverseSlope = -1 / slope;
+
+ console.log('slope', slope);
+ console.log('inverse slope', inverseSlope);
+
+ let smlArcAngle = Math.atan(pointDistanceInInches / (6 * calcY)) * 2;
+ let distance = Math.sqrt((x2px - x1px)**2 + (y2px - y1px)**2);
+ let newY1 = y2px + distance * Math.atan(smlArcAngle / 2);
+ let newY2 = y2px - distance * Math.atan(smlArcAngle / 2);
+
+ // p.setAttributeNS(null, 'points', `${newX},${newY} ${x1px},${y1px} ${newX},${newY}`);
+ // p.setAttributeNS(null, 'points', `${x2px},${y2px} ${x1px},${y1px} ${x2px},${y2px}`);
+ p.setAttributeNS(null, 'points', `${x2px},${newY1} ${x1px},${y1px} ${x2px},${newY2}`);
+
+ console.log(p);
if (x2 - x1 > 0 && y2 - y1 > 0) {
let yWhenXisMax = yIntercept(maxX);