简体   繁体   English

重力如何影响向量

[英]How does gravity affect a vector

My apologies if you think this question is supposed to be on the Math exchange, they scare me a bit and their answers usually don't make any sense to me. 如果您认为这个问题应该在数学交流中进行,我深表歉意,他们让我有些恐惧,他们的回答通常对我没有任何意义。

Right, I'm trying to get very basic physics in Javascript. 是的,我正在尝试用Java语言获得非常基础的物理学。 I have a vector(direction and magnitude) and I need to modify both direction and magnitude because... well... gravity. 我有一个向量(方向和大小),我需要修改方向和大小,因为...好吧...重力。 I do know how to calculate it all using an x and y speed, but I wanted to go for a different approach this time and use vectors instead though I'm failing to understand it. 我确实知道如何使用x和y速度来计算所有这些,但是这次我想采用另一种方法,而是使用向量,尽管我无法理解它。

I'm sorry for giving so little information, but I'm clueless... 很抱歉提供的信息很少,但是我一无所知...

particle.velocity.angle += ?;
particle.velocity.speed += ?;

What's the equation of modifying the angle and speed of a vector using an acceleration? 用加速度修改矢量的角度和速度的方程式是什么?

Rather than storing velocity as angle and speed, store it as x speed and y speed. 而不是将速度存储为角度和速度,而是将其存储为x速度和y速度。 Then gravity affects the y speed, but not the x speed. 然后,重力会影响y速度,但不会影响x速度。 Gravity is a force, so it accelerates, meaning the change in speed is constant. 重力是一种力量,因此它会加速,这意味着速度的变化是恒定的。 At every time delta, change the y speed by the same amount, and you'll get a gravity effect. 在每个时间增量处,将y速度更改相同的量,您将获得重力效果。

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

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