I'm trying to move a ship to a target point by accelerating in one direction and then accelerating in the opposite direction to bring the ship to a stop, but I can't quite get it right.
It's entirely a 1D problem and we don't need to consider mass.
I have the following information: current position, target position, distance to target, current total velocity, current acceleration in both directions (forward and back), acceleration rate.
How can I work out when to properly accelerate in the opposite direction to come to a complete stop as close to the target as possible? It's okay if it overshoots by a bit.
forward and backwards acceleration? Uhhh... You only need one acceleration since the resultant acceleration is the same regardless... It's like:
2 = 3-1 = 4-2 = 5-3 =...
that being said, you wanna have your final velocity = 0 and acceleration = 0 when you get there, which you can just turn off, it doesn't have to happen smoothly.
Parker Cook
looks like overkill (and greek)
seems silly
seems like overkill
forward acceleration would be like, the amount of burn on the main engine in the rear and backward acceleration would be like, the amount of burn on the engines at the front of the ship
Xavier Morales
Yeah. I'm telling you don't do that
1 unit of forward acceleration and 2 units of backwards acceleration is the same as just 1 unit of backwards acceleration.
Juan Flores
Seeing your webm and how the ship slowly re-accelerates, I'm almost 100% sure its a rounding problem. The reason that happens is because there's a very tiny "leftover" of the right-side acceleration that compounds on itself because of the flawed code you've written
Round the velocity better and have it simply equate to 0 should you reach a low enough threshold, that way you wont get an unrounded 0.0000001 leftover that will compound to high speeds.
Wyatt Perry
So we know x, delta x, and v max. If we don't, you need to set the max v. You can let v max be dependent on the distance.
v(t0)=0, v(delta t) = 0, and somewhere in the middle we want a max.
x-x^2 is a good polynomial that goes through zero twice, so you could let [math] \displaystyle v(t)= \frac {-4 v_m t^2 + 4 v_m \Delta \mathbb { x } t } { \Delta \mathbb{ x } ^ 2 } [/math]
Which would make [math] \displaystyle x(t) = \frac { \frac {-4 v_m } {3} t^3 + \frac {4 v_m \Delta \mathbb { x } } {3} t^3 } { \Delta \mathbb { x } ^ 2 } [/math] by taking an integral.
Finally, acceleration would be [math] \displaystyle a(t) = \frac {-8 v_m t + 4 v_m \Delta \mathbb { x } } { \Delta \mathbb { x } ^2 } [/math]
You could use any equation you want, I just thought a simple polynomial would do the trick. You could mess around with some sliders on desmos.com/calculator to see what that actually looks like.
Colton Harris
Oops, for x(t), it should be (for the added part) ...-4v_m t^3 / 3 + [math]2 v_m \Delta \mathbb { x } t^2[/math] instead of the 4/3 I had before.
Jackson Cook
are you retarded? you must be retarded. >just fucking blast the ship forward to the point and then hardcode a full stop, it doesnt have to look real. >this is equivalent to smoothly accelerating halfway towards the target, then reversing the acceleration so you come to a stop on target, which is what the OP wants and how it would work in real world physics.
Liam Rivera
>looks like overkill (and greek) OP if you cant be bothered to model the actual math involved its not going to look real...and you wonder why you are having a problem?
besides, it's not like that is hard math to code, ffs pull your thumb out of your ass
Lucas Kelly
Thiiiiiiis
OP have you really not ever taken wildlinalg?
Lincoln Rivera
Are you retarded OP?
David Fisher
No you don't understand that discontinuities in acceleration don't correspond to discontinuities in velocity. Take an intro physics course when you get out of HS.
Lucas Sanchez
How do I do that when A is moving, and B can (and will) move, though?
Matthew Gray
Figured it out. Thanks for nothing brainiacs.
Good luck with the eventual suicide once your research careers sputter out.
Logan Torres
this is not how space ships work
Isaac Davis
Did you use PID control
Joseph Howard
>spaecshit magically just decelerates THere's no fucking drag in space retard.
Michael Campbell
Good luck spending your life making gaymes you dumb cock monkey faggot.
Henry Murphy
If he didn't want to use basic kinematics equations, I doubt he was able to implement a PID loop.
Brayden Peterson
>looks like overkill
Jaxon Anderson
>>not using trapezoidal acceleration profiles I really hope you enjoy that jerk and higher order shocks
that does not look real at all.
Use a trapezoidal acceleration profile. Pic related. It's easy mode, it's just geometry.
Camden Miller
This is so fucking retarded, why would you even bother posting this nonsense that doesn't even try to answer the question?
Carson Cook
You need at minimum a third degree polynomial to describe the acceleration. All you have to do is find the constants that satisfy the following