简体   繁体   English

两个运动物体的交点

[英]Intersection of two Moving Objects

I'm trying to use the answer provided here: Intersection of two Moving Objects with Latitude/Longitude Coordinates 我正在尝试使用此处提供的答案: 具有纬度/经度坐标的两个运动对象的交点

But I have some questions.. 但是我有一些问题。

What is this angle: 这个角度是多少:

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

I was thinking that the angle that should be used in the law of cosines is already "alpha or target.dir".. What is that line doing? 我当时在考虑余弦定律中应该使用的角度已经是“ alpha或target.dir”。。这条线在做什么? Also in these two steps: 同样在以下两个步骤中:

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

Shouldn't the code be using the angle between x- or y-axis and the target velocity vector? 代码不应该使用x轴或y轴与目标速度矢量之间的角度吗? Why is the author using alpha here? 为什么作者在这里使用alpha?

在此处输入图片说明

What is this angle: 这个角度是多少:

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

The variable named angle is indeed the angle alpha . 名为angle的变量确实是角度alpha Because the direction dir is the direction from chaser to target, and we need it the other way round for this calculation, we add π to it before we subtract target.dir . 因为dir方向是从追赶者到目标的方向,并且我们需要反方向进行此计算,所以我们在减去target.dir之前向其中添加π。

Maybe using the word angle as a variable name was a bit vague; 也许将angle用作变量名有点含糊; I'll change it to alpha , the name I used for this angle in the images. 我将其更改为alpha ,即图像中用于此角度的名称。

Shouldn't the code be using the angle between x- or y-axis and the target velocity vector? 代码不应该使用x轴或y轴与目标速度矢量之间的角度吗? Why is the author using alpha here? 为什么作者在这里使用alpha?

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

We are indeed using target.dir , which is the direction of the target, ie the angle between the x-axis and the target vector, to calculate the coordinates of the interception point, and not the angle alpha. 我们确实使用target.dir (它是目标的方向,即x轴与目标矢量之间的角度)来计算截取点的坐标,而不是角度α。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM