Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6718165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:56:14+00:00 2026-05-26T08:56:14+00:00

So I have a ship, that has thrusters at the bottom and that can

  • 0

So I have a ship, that has thrusters at the bottom and that can only use these to move forward. It can also rotate itself around its center. Its thrusters gives it acceleration, so it doesn’t move at a constant velocity. What I want to do is to tell it “move to point B”.

I have come up with a solution but it doesn’t work very well and it doesn’t rotate smoothly, it moves jerkily and it doesn’t end up exactly where it should be, so I have to have a big margin of error.

Is this a normal problem, and if so is there a “standard” way of doing it? Is this an easy problem? I want to make it look like the ship is steering itself to that point, using the constraints (thrusters, rotation) the player has. This excludes just lerping it from point A to B. Or does it?

I’d love some help in solving this problem. Positions are stored in vectors, and it’s a 2D problem. Just for reference I’m including my solution, which basically is accelerating the ship until and rotating it to point to the point. I think my implementation of this idea is the problem:

Vector diff = vector_sub(to_point, pos);
float angle = vector_getangle(diff);
float current_angle = vector_getangle(dir);
float angle_diff = rightrange(angle) - rightrange(current_angle);
float len = vector_getlength(diff);

// "Margin of error"
float margin = 15.0;

// Adjust direction, only if we're not stopping the next thing we do (len <= margin)
if ( len > margin && fabs(angle_diff) > 2.0 )
{
    dir = vector_setangle(dir, current_angle + (angle_diff)*delta*(MY_PI) - MY_PI/2);
}
else if ( len > margin )
{
    dir = vector_normalize(diff);
}

// accelerate ship (if needed)
acc.x = acc.y = speed;
acc = vector_setangle(acc, vector_getangle(dir));

if ( len <= margin )
{
    // Player is within margin of error
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:56:15+00:00Added an answer on May 26, 2026 at 8:56 am

    If you are not looking for a very general solution that works online, then there is a simple solution. What I mean by online is continuously re-calculating the actions along the complete trajectory.

    Assuming the ship is at rest at start, simply rotate it towards your target point (while still at rest). Now, your ship can reach the target by accelerating for t seconds, rotating back while in motion (for 0.5 seconds as per your constraint), and decelerating for another t seconds. If the distance between current point and destination is d, then the equation you need to solve is:

    d = 0.5*a*t^2 + 0.5*a*t + 0.5*a*t^2
    

    The first term is distance traveled while accelerating. The second term is distance traveled while rotating (v*t_rot, v=a*t, t_rot=0.5). The final term is the distance traveled while decelerating. Solve the above for t, and you have your trajectory.

    If the ship is moving at start, I would first stop it (just rotate in opposite direction of its speed vector, and decelerate until at rest). Now we know how to reach destination.

    The problem with offline trajectory calculation is that it is not very accurate. There is a good chance that you will end up in the vicinity of the target, but not exactly on top of it.


    Let’s make the problem a little more interesting: the ship cannot rotate without acceleration. Let’s call this acceleration vector a_r, a vector that is at a certain angle against the ship’s direction (somewhat like having a thruster at an angle at the back). Your task now is to rotate the ship and accelerate in such a direction that the speed component perpendicular to the vector connecting the current position to the target is canceled out. Instead of trying to calculate the vectors offline, I would go with an online approach with this.

    The easiest thing to do would be to add the following algorithm calculated at every time interval:

    1. Calculate the vector pointing from ship to destination.
    2. Split your current speed vector into two components: towards the destination, and perpendicular to it.
    3. If perpendicular speed is zero, skip 4
    4. Start rotating towards the negative of the perpendicular vector’s direction. If already looking away from it (not exact opposite, but just looking away), also fire main thruster.

    This will oscillate a bit, I suspect it will also stabilize after a while. I must admit, I don’t know how I would make it stop at destination.


    And the final approach is to model the ship’s dynamics, and try to linearize it. It will be a non-linear system, so the second step will be necessary. Then convert the model to a discrete time system. And finally apply a control rule to make it reach target point. For this, you can change your state-space from position and speed to error in position and (maybe) error in speed, and finally add a regulation control (a control loop that takes the current state, and generates an input such that the state variables will approach zero).

    This last one is fairly difficult in the maths compartment, and you’d probably need to study control engineering a bit to do it. However, you’ll get much better results than the above simplistic algorithm – which admittedly might not even work. In addition, you can now apply various optimization rules to it: minimize time to reach target, minimize fuel consumption, minimize distance traveled, etc.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to ship some groovy code to some users that have only java
We have a product that we need to create an installer for. It has
i have a dependancy on MSXML 4.0. Microsoft has a page that gives the
I have a database that has lots of data and is all neat, normalized
I have 2 tables that have a relation ship to each other Table A
I have a ComboBox that has its ItemSource and SelectedItem properties bound to a
The hindrance we have to ship python is the large size of the standard
I am doing a list of items I have to ship, with every item
I have a class called Ship and a class called Lifeboat Lifeboat inherits from
I have an NAnt task ship to package my current .sql scripts into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.