MySQL - determining the position of an object in motion

问题: I have been looking this up for weeks. I have no background in physics, and the Greek makes it very confusing to interpret. I am making a game exclusively in MySQL, mainl...

问题:

I have been looking this up for weeks. I have no background in physics, and the Greek makes it very confusing to interpret.

I am making a game exclusively in MySQL, mainly for the challenge. The concept is an idle space RPG, kind of like EVE online but meant to be completely automated...

So, the map is in 3d, with x,y,z representing each dimension. I have the formula for finding the distance between two points in MySQL:

(POW((X-@x),2)+POW((Y-@y),2)+POW((Z-@z),2))

If you take the distance and divide it by the speed, we can get the time that we would arrive. The question is, how do you find out where the object is mid-flight?

Find the distance between two points:

create table stars (id int auto_increment primary key, x decimal(65,8),y decimal(65,8), z decimal(65,8));
insert into stars (x,y,z) VALUES ("0","0","0"),("1000.00","3000.00","2500.00");

set @id = 1,
    @x = (select x from stars where id =@id),
    @y = (select y from stars where id =@id),
    @z = (select z from stars where id =@id);
SELECT (POW((X-@x),2)+POW((Y-@y),2)+POW((Z-@z),2)) as distance 
FROM stars where id = 2;

The travel_time would be distance/speed. Without taking into acceleration or gravity, how do we determine the position of the object when it is halfway through its flight?

I believe this is the formula:

!(https://i.gyazo.com/9f097dc9f13e644a72ec84d8abcd9033.png)!


回答1:

$$ Big(frac{(1-t)x_1+tx_2}{2},frac{(1-t)y_1+2y_2}{2},frac{(1-t)z_1+tz_2}{2} Big) $$

https://math.stackexchange.com/q/3126712/648433

  • 发表于 2019-03-01 01:49
  • 阅读 ( 153 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除