javascript - 两个运动物体的交点

标签 javascript math

我正在尝试使用此处提供的答案:Intersection of two Moving Objects with Latitude/Longitude Coordinates

但是我有一些问题..

这个 Angular 是多少:

var angle = Math.PI + dir - target.dir

我在想余弦定律中应该使用的 Angular 已经是“alpha or target.dir”。那条线在做什么?同样在这两个步骤中:

 var x = target.x + target.vel * time * Math.cos(target.dir); 
 var y = target.y + target.vel * time * Math.sin(target.dir);  

代码不应该使用 x 轴或 y 轴与目标速度矢量之间的 Angular 吗?为什么作者在这里使用 alpha?

enter image description here

最佳答案

What is this angle:

var angle = Math.PI + dir - target.dir

名为angle 的变量确实是 Angular alpha。因为方向 dir 是从追赶者到目标的方向,而我们在计算中需要相反的方向,所以我们在减去 target.dir 之前加上 π。

也许使用 Angular 这个词作为变量名有点含糊;我会将其更改为 alpha,这是我在图像中用于此 Angular 名称。

Shouldn't the code be using the angle between x- or y-axis and the target velocity vector? Why is the author using alpha here?

var x = target.x + target.vel * time * Math.cos(target.dir);  
var y = target.y + target.vel * time * Math.sin(target.dir);  

我们确实是使用target.dir,也就是目标的方向,即x轴与目标向量的夹 Angular ,来计算截取点的坐标,而不是 Angular 阿尔法。

关于javascript - 两个运动物体的交点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57745068/

相关文章:

c# - 结果范围为 0 - 360 的两个 3D 矢量之间的角度

javascript - 扩展 TypeScript 的控制台界面

c# - JavaScript float 错误

math - 防止TI BASIC表达式扩展

java - 如何在 Java 中有效生成完美的数字到数字不变数?

algorithm - 多边形添加算法

javascript - jQuery .each() 仅适用于最后一个元素

Javascript:两个不同的对象共享一个数组属性?

Javascript 在 while 循环中更改不透明度不起作用

c++ - 速度基于时间而不是 FPS