javascript - Finding the time of contact between two objects on the same collision path? -


i'm trying find time take (if @ all) 2 objects on path of collision contact, proving hard glass of wine hand.

for arguments sake, , in javascript:

var pointa = { x: 0 } var pointb = { x: 100 }  var pointatraveltime = 1000; // milliseconds var pointbtraveltime = 2000; // milliseconds  var pointatimeout = settimeout(function () {    pointa.x = 200; // pointa arrive here in pointatraveltime  }, pointatraveltime);  var pointbtimeout = settimeout(function () {    pointb.x = 0; // pointb arrive here in pointbtraveltime  }, pointbtraveltime); 

in theory, how can calculate time take pointa , pointb collide, given going @ different speeds?

thanks.

this not hard, basic math.

pointa moving at, let's 100 m/s. pointb moving at, half of that, 50 m/s. they're both heading towards each other

the formula : time = distance/velocity

let's distance 100m

in case :

100m / (100m/s + 50m/s)

= 100/150

= 0,666..s

and there have it. 2 points meet @ 0.666s.

this not hard implement in programming language, i'm wondering why post sort of question on stackoverflow.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -