Problem 44365. An asteroid and a spacecraft
🚀 Imagine a non-relativistic simple situation.
Assume positions p0, p1, p2, and p3 are three dimensional Cartesian coordinates.
Your spacecraft started from the position p0 at time t0.
Your spacecraft is moving with a constant velocity.
Your spacecraft is expected to reach a star at the location p1 at time t1.
You just heard over the radio that an asteroid has been identified at the location p2 at time t0.
The asteroid is moving with a constant velocity.
The asteroid is expected to reach another star at the location p3 at time t1.
You need to write a code 'safetrip' in MATLAB to return true if the minimum distance between your spacecraft and the asteroid will be more than the distance d during the time interval between t0 and t1, otherwise return false.
Solution Stats
Problem Comments
-
3 Comments
Needs more test cases to eliminate the the trivial non-solution that exploits the lack of test cases.
This problem needs more test cases. My solution probably is not general, but it works without using all of its tests.
An interesting test case, for instance, would be (that my solution and many others would fail):
p0 = [1, 0, 0];
p1 = [ -1, 0, 0];
p2 = [ 0, 1, 0.5];
p3 = [ 0, -1, 0.5];
t0 = 0;
t1 = 1;
d = 1;
ok = false;
At half-way their path, asteroid and spacecraft will be at distance 0.5 of each other, violating the safe distance d=1, and without crossing paths.
Solution Comments
Show commentsProblem Recent Solvers159
Suggested Problems
-
Find state names that end with the letter A
1184 Solvers
-
Numbers with prime factors 2, 3 and 5.
570 Solvers
-
Area of an equilateral triangle
6300 Solvers
-
Solving Quadratic Equations (Version 1)
488 Solvers
-
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
1702 Solvers
More from this Author100
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!