WIP: firing arcs: fix cone angle calculation
This commit is contained in:
parent
7da963cd8e
commit
aba937c459
19
index.js
19
index.js
@ -115,14 +115,19 @@ rect.addEventListener('mousemove', e => {
|
||||
|
||||
console.log('angle', angle, 'degrees', radToDeg(angle));
|
||||
|
||||
let smlArcAngle = Math.atan(pointDistanceInInches / (6 * calcY)) * 2;
|
||||
let smlArcAngle = Math.atan(pointDistanceInInches / (6 * calcY));
|
||||
let medArcAngle = Math.atan((pointDistanceInInches / 2) / calcY);
|
||||
let lrgArcAngle = Math.atan((21 * pointDistanceInInches) / (6 * calcY));
|
||||
|
||||
let arcAngle = lrgArcAngle;
|
||||
|
||||
let distance = Math.sqrt((x2px - x1px)**2 + (y2px - y1px)**2);
|
||||
|
||||
let newY1 = y2px + (distance * Math.cos(angle)) * Math.atan(smlArcAngle / 2);
|
||||
let newY2 = y2px - (distance * Math.cos(angle)) * Math.atan(smlArcAngle / 2);
|
||||
let newY1 = y2px + (distance * Math.cos(angle)) * Math.tan(arcAngle);
|
||||
let newY2 = y2px - (distance * Math.cos(angle)) * Math.tan(arcAngle);
|
||||
|
||||
let newX1 = x2px + (distance * Math.sin(angle)) * Math.atan(smlArcAngle / 2);
|
||||
let newX2 = x2px - (distance * Math.sin(angle)) * Math.atan(smlArcAngle / 2);
|
||||
let newX1 = x2px + (distance * Math.sin(angle)) * Math.tan(arcAngle);
|
||||
let newX2 = x2px - (distance * Math.sin(angle)) * Math.tan(arcAngle);
|
||||
|
||||
// p.setAttributeNS(null, 'points', `${newX},${newY} ${x1px},${y1px} ${newX},${newY}`);
|
||||
// p.setAttributeNS(null, 'points', `${x2px},${y2px} ${x1px},${y1px} ${x2px},${y2px}`);
|
||||
@ -176,6 +181,10 @@ rect.addEventListener('mousemove', e => {
|
||||
}
|
||||
}
|
||||
|
||||
distance = Math.sqrt((x2 - x1)**2 + (y2 - y1)**2);
|
||||
newY = y2 + (distance * Math.cos(angle)) * Math.tan(arcAngle);
|
||||
newX = x2 + (distance * Math.sin(angle)) * Math.tan(arcAngle);
|
||||
|
||||
aim.setAttributeNS(null, 'x2', `${newX}in`);
|
||||
aim.setAttributeNS(null, 'y2', `${newY}in`);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user