Skip to main content
Rollback to Revision 8
Source Link
doppelgreener
  • 7.3k
  • 7
  • 43
  • 69

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at (0,0)\$(0,0)\$; to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Unfortunately, without latex, I can't format this answer very well, but we'll attempt to make do. Let:

  • s_s\$s_s\$ = the ship's speed (s_s.x, s_s.y\$s_s.x, s_s.y\$, likewise)
  • s_a\$s_a\$ = the ship's bearing (angle of movement, what we want to calculate)
  • p_p\$p_p\$ = the planet's initial position, global coords
  • p_r\$p_r\$ = the planet's distance (radius) from the center of orbit, derivable from p_p\$p_p\$
  • p_a\$p_a\$ = the planet's initial angle in radians, relative to the center of orbit
  • p_s\$p_s\$ = the planet's angular velocity (rad/sec)
  • t\$t\$ = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components: $$ ship.x = s_s.x * t * cos(s_a) $$ $$ ship.y = s_s.y * t * sin(s_a) $$ $$ planet.x = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ planet.y = p_r * sin(p_a + p_s * t) + p_p.y $$

ship.x = s_s.x * t * cos(s_a)
ship.y = s_s.y * t * sin(s_a)

planet.x = p_r * cos(p_a + p_s * t) + p_p.x
planet.y = p_r * sin(p_a + p_s * t) + p_p.y

Since we want ship.x = planet.x\$ship.x = planet.x\$ and ship.y = planet.y\$ship.y = planet.y\$ at some instant t\$t\$, we obtain this equation (the y\$y\$ case is nearly symmetrical):

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
   s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y $$

Solving the top equation for s_a\$s_a\$:

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
=> s_a = arccos((p_r * cos(p_a + p_s * t) + p_p.x) / (s_s.x * t))

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x \\ \implies s_a = \frac{arccos((p_r * cos(p_a + p_s * t) + p_p.x)}{(s_s.x * t))}$$

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at (0,0); to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Unfortunately, without latex, I can't format this answer very well, but we'll attempt to make do. Let:

  • s_s = the ship's speed (s_s.x, s_s.y, likewise)
  • s_a = the ship's bearing (angle of movement, what we want to calculate)
  • p_p = the planet's initial position, global coords
  • p_r = the planet's distance (radius) from the center of orbit, derivable from p_p
  • p_a = the planet's initial angle in radians, relative to the center of orbit
  • p_s = the planet's angular velocity (rad/sec)
  • t = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components:

ship.x = s_s.x * t * cos(s_a)
ship.y = s_s.y * t * sin(s_a)

planet.x = p_r * cos(p_a + p_s * t) + p_p.x
planet.y = p_r * sin(p_a + p_s * t) + p_p.y

Since we want ship.x = planet.x and ship.y = planet.y at some instant t, we obtain this equation (the y case is nearly symmetrical):

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
   s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y

Solving the top equation for s_a:

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
=> s_a = arccos((p_r * cos(p_a + p_s * t) + p_p.x) / (s_s.x * t))

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at \$(0,0)\$; to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Let:

  • \$s_s\$ = the ship's speed (\$s_s.x, s_s.y\$, likewise)
  • \$s_a\$ = the ship's bearing (angle of movement, what we want to calculate)
  • \$p_p\$ = the planet's initial position, global coords
  • \$p_r\$ = the planet's distance (radius) from the center of orbit, derivable from \$p_p\$
  • \$p_a\$ = the planet's initial angle in radians, relative to the center of orbit
  • \$p_s\$ = the planet's angular velocity (rad/sec)
  • \$t\$ = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components: $$ ship.x = s_s.x * t * cos(s_a) $$ $$ ship.y = s_s.y * t * sin(s_a) $$ $$ planet.x = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ planet.y = p_r * sin(p_a + p_s * t) + p_p.y $$

Since we want \$ship.x = planet.x\$ and \$ship.y = planet.y\$ at some instant \$t\$, we obtain this equation (the \$y\$ case is nearly symmetrical):

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y $$

Solving the top equation for \$s_a\$:

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x \\ \implies s_a = \frac{arccos((p_r * cos(p_a + p_s * t) + p_p.x)}{(s_s.x * t))}$$

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Rollback to Revision 7
Source Link
doppelgreener
  • 7.3k
  • 7
  • 43
  • 69

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at \$(0,0)\$(0,0); to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Unfortunately, without latex, I can't format this answer very well, but we'll attempt to make do. Let:

  • \$s_s\$s_s = the ship's speed (\$s_s.x, s_s.y\$s_s.x, s_s.y, likewise)
  • \$s_a\$s_a = the ship's bearing (angle of movement, what we want to calculate)
  • \$p_p\$p_p = the planet's initial position, global coords
  • \$p_r\$p_r = the planet's distance (radius) from the center of orbit, derivable from \$p_p\$p_p
  • \$p_a\$p_a = the planet's initial angle in radians, relative to the center of orbit
  • \$p_s\$p_s = the planet's angular velocity (rad/sec)
  • \$t\$t = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components: $$ ship.x = s_s.x * t * cos(s_a) $$ $$ ship.y = s_s.y * t * sin(s_a) $$ $$ planet.x = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ planet.y = p_r * sin(p_a + p_s * t) + p_p.y $$

ship.x = s_s.x * t * cos(s_a)
ship.y = s_s.y * t * sin(s_a)

planet.x = p_r * cos(p_a + p_s * t) + p_p.x
planet.y = p_r * sin(p_a + p_s * t) + p_p.y

Since we want \$ship.x = planet.x\$ship.x = planet.x and \$ship.y = planet.y\$ship.y = planet.y at some instant \$t\$t, we obtain this equation (the \$y\$y case is nearly symmetrical):

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y $$

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
   s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y

Solving the top equation for \$s_a\$s_a:

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x \\ \implies s_a = \frac{arccos((p_r * cos(p_a + p_s * t) + p_p.x)}{(s_s.x * t))}$$

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
=> s_a = arccos((p_r * cos(p_a + p_s * t) + p_p.x) / (s_s.x * t))

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at \$(0,0)\$; to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Let:

  • \$s_s\$ = the ship's speed (\$s_s.x, s_s.y\$, likewise)
  • \$s_a\$ = the ship's bearing (angle of movement, what we want to calculate)
  • \$p_p\$ = the planet's initial position, global coords
  • \$p_r\$ = the planet's distance (radius) from the center of orbit, derivable from \$p_p\$
  • \$p_a\$ = the planet's initial angle in radians, relative to the center of orbit
  • \$p_s\$ = the planet's angular velocity (rad/sec)
  • \$t\$ = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components: $$ ship.x = s_s.x * t * cos(s_a) $$ $$ ship.y = s_s.y * t * sin(s_a) $$ $$ planet.x = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ planet.y = p_r * sin(p_a + p_s * t) + p_p.y $$

Since we want \$ship.x = planet.x\$ and \$ship.y = planet.y\$ at some instant \$t\$, we obtain this equation (the \$y\$ case is nearly symmetrical):

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y $$

Solving the top equation for \$s_a\$:

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x \\ \implies s_a = \frac{arccos((p_r * cos(p_a + p_s * t) + p_p.x)}{(s_s.x * t))}$$

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at (0,0); to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Unfortunately, without latex, I can't format this answer very well, but we'll attempt to make do. Let:

  • s_s = the ship's speed (s_s.x, s_s.y, likewise)
  • s_a = the ship's bearing (angle of movement, what we want to calculate)
  • p_p = the planet's initial position, global coords
  • p_r = the planet's distance (radius) from the center of orbit, derivable from p_p
  • p_a = the planet's initial angle in radians, relative to the center of orbit
  • p_s = the planet's angular velocity (rad/sec)
  • t = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components:

ship.x = s_s.x * t * cos(s_a)
ship.y = s_s.y * t * sin(s_a)

planet.x = p_r * cos(p_a + p_s * t) + p_p.x
planet.y = p_r * sin(p_a + p_s * t) + p_p.y

Since we want ship.x = planet.x and ship.y = planet.y at some instant t, we obtain this equation (the y case is nearly symmetrical):

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
   s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y

Solving the top equation for s_a:

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
=> s_a = arccos((p_r * cos(p_a + p_s * t) + p_p.x) / (s_s.x * t))

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Converted formulae to MathJax, removed MathJax request from post.
Source Link
Will
  • 244
  • 1
  • 11

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at (0,0)\$(0,0)\$; to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Unfortunately, without latex, I can't format this answer very well, but we'll attempt to make do. Let:

  • s_s\$s_s\$ = the ship's speed (s_s.x, s_s.y\$s_s.x, s_s.y\$, likewise)
  • s_a\$s_a\$ = the ship's bearing (angle of movement, what we want to calculate)
  • p_p\$p_p\$ = the planet's initial position, global coords
  • p_r\$p_r\$ = the planet's distance (radius) from the center of orbit, derivable from p_p\$p_p\$
  • p_a\$p_a\$ = the planet's initial angle in radians, relative to the center of orbit
  • p_s\$p_s\$ = the planet's angular velocity (rad/sec)
  • t\$t\$ = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components: $$ ship.x = s_s.x * t * cos(s_a) $$ $$ ship.y = s_s.y * t * sin(s_a) $$ $$ planet.x = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ planet.y = p_r * sin(p_a + p_s * t) + p_p.y $$

ship.x = s_s.x * t * cos(s_a)
ship.y = s_s.y * t * sin(s_a)

planet.x = p_r * cos(p_a + p_s * t) + p_p.x
planet.y = p_r * sin(p_a + p_s * t) + p_p.y

Since we want ship.x = planet.x\$ship.x = planet.x\$ and ship.y = planet.y\$ship.y = planet.y\$ at some instant t\$t\$, we obtain this equation (the y\$y\$ case is nearly symmetrical):

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
   s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y $$

Solving the top equation for s_a\$s_a\$:

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
=> s_a = arccos((p_r * cos(p_a + p_s * t) + p_p.x) / (s_s.x * t))

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x \\ \implies s_a = \frac{arccos((p_r * cos(p_a + p_s * t) + p_p.x)}{(s_s.x * t))}$$

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at (0,0); to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Unfortunately, without latex, I can't format this answer very well, but we'll attempt to make do. Let:

  • s_s = the ship's speed (s_s.x, s_s.y, likewise)
  • s_a = the ship's bearing (angle of movement, what we want to calculate)
  • p_p = the planet's initial position, global coords
  • p_r = the planet's distance (radius) from the center of orbit, derivable from p_p
  • p_a = the planet's initial angle in radians, relative to the center of orbit
  • p_s = the planet's angular velocity (rad/sec)
  • t = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components:

ship.x = s_s.x * t * cos(s_a)
ship.y = s_s.y * t * sin(s_a)

planet.x = p_r * cos(p_a + p_s * t) + p_p.x
planet.y = p_r * sin(p_a + p_s * t) + p_p.y

Since we want ship.x = planet.x and ship.y = planet.y at some instant t, we obtain this equation (the y case is nearly symmetrical):

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
   s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y

Solving the top equation for s_a:

   s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x
=> s_a = arccos((p_r * cos(p_a + p_s * t) + p_p.x) / (s_s.x * t))

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

Here's part of a solution. I didn't get to finish it in time. I'll try again later.

If I understand correctly, you have a planet's position & velocity, as well as a ship's position and speed. You want to get the ship's movement direction. I'm assuming the ship's and planet's speeds are constant. I also assume, without loss of generality, that the ship is at \$(0,0)\$; to do this, subtract the ship's position from the planet's, and add the ship's position back onto the result of the operation described below.

Let:

  • \$s_s\$ = the ship's speed (\$s_s.x, s_s.y\$, likewise)
  • \$s_a\$ = the ship's bearing (angle of movement, what we want to calculate)
  • \$p_p\$ = the planet's initial position, global coords
  • \$p_r\$ = the planet's distance (radius) from the center of orbit, derivable from \$p_p\$
  • \$p_a\$ = the planet's initial angle in radians, relative to the center of orbit
  • \$p_s\$ = the planet's angular velocity (rad/sec)
  • \$t\$ = the time to collision (this turns out to be something we must calculate as well)

Here's the equations for the position of the two bodies, broken down into components: $$ ship.x = s_s.x * t * cos(s_a) $$ $$ ship.y = s_s.y * t * sin(s_a) $$ $$ planet.x = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ planet.y = p_r * sin(p_a + p_s * t) + p_p.y $$

Since we want \$ship.x = planet.x\$ and \$ship.y = planet.y\$ at some instant \$t\$, we obtain this equation (the \$y\$ case is nearly symmetrical):

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x $$ $$ s_s.y * t * sin(s_a) = p_r * sin(p_a + p_s * t) + p_p.y $$

Solving the top equation for \$s_a\$:

$$ s_s.x * t * cos(s_a) = p_r * cos(p_a + p_s * t) + p_p.x \\ \implies s_a = \frac{arccos((p_r * cos(p_a + p_s * t) + p_p.x)}{(s_s.x * t))}$$

Substituting this into the second equation results in a fairly terrifying equation that Wolfram alpha won't solve for me. There may be a better way to do this not involving polar coordinates. If anyone wants to give this method a shot, you're welcome to it; I've made this a wiki. Otherwise, you may want to take this to the Math StackExchange.

replaced http://meta.stackexchange.com/ with https://meta.stackexchange.com/
Source Link
Loading
fix math site name
Source Link
AakashM
  • 251
  • 1
  • 5
Loading
added 31 characters in body
Source Link
Chaosed0
  • 773
  • 5
  • 17
Loading
Post Undeleted by Chaosed0
corrected link; added 87 characters in body
Source Link
Chaosed0
  • 773
  • 5
  • 17
Loading
corrected everything; added 86 characters in body
Source Link
Chaosed0
  • 773
  • 5
  • 17
Loading
added 112 characters in body
Source Link
Chaosed0
  • 773
  • 5
  • 17
Loading
Post Deleted by Chaosed0
Source Link
Chaosed0
  • 773
  • 5
  • 17
Loading
Post Made Community Wiki by Chaosed0