Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PutShipOnRoute function #5250

Conversation

Gliese852
Copy link
Contributor

After placing the ship on the route, the possibility of a collision is checked. In case of a possible collision, its position is changed to avoid this. It turns out that this calculation worked incorrectly, because the FromVectors function creates a matrix using vectors as
columns, and in the further calculation it is assumed that vectors are rows.

Also removed unnecessary Frame object retrieval by FrameId.

This video shows that now everything is working as it should (at least in the video). The dangerous trajectory that was originally shown in red, the new safe trajectory is shown in blue, and the alternative trajectory (also safe, but on the other side of the obstructor) in gray.

coll.mp4

Two cases are shown - when the ship is out of the target frame, and when it is in the same frame with the target. In the first case, the trajectory turns so as not to fall into a dangerous proximity, and in the second case, the ship moves to the normal to the planet's surface.

After placing the ship on the route, the possibility of a collision is
checked.  In case of a possible collision, its position is changed to
avoid this. It turns out that this calculation worked incorrectly,
because the FromVectors function creates a matrix using vectors as
columns, and in the further calculation it is assumed that vectors are
rows.

Also removed unnecessary Frame object retrieval by FrameId
Copy link
Contributor

@fluffyfreak fluffyfreak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, and I love a good debug visualisation video!

@impaktor
Copy link
Member

Will merge within 24 h if no one objects

Comment on lines 270 to 273
if (shipFrame->GetNonRotFrame() != targFrame->GetNonRotFrame() && targpos.Length() > erad) {
// the ship is not in the target's frame or target is above the effective radius of obstructor - rotate the ship's position
// around the target position, so that the obstructor's "effective radius" does not cross the path
// direction obstructor -> target
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting dillemma here, the code checks that we are both not in the same frame and further than the effective radius, however the comment is saying that this is an 'or' condition - what happens if we are in the same frame but beyond effective radius?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Web-eWorks Really weird. After paradoxically long deliberation, it seems to me that we need to change the comment to "and", because we want to enter the sphere of effective radius of obstructor only perpendicular to it, even if for some reason the target is not in the obstructor frame. (perhaps it could be an orbital station, in a very very low orbit?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Web-eWorks if we are in the same frame but the target is beyond effective radius, like in any other case, when the target is beyond the effective radius, we can calculate the tangent, so option 1 can be used. I think I should remove the frame check at all.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free - I'm not particularly familiar with this algorithm, but that inconsistency stood out.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Web-eWorks done!

The choice of trajectory correction method depends only on whether we
can calculate the tangent to the sphere of the effective radius of the
obstructor from the target. We cannot do this if the target is within
this sphere. All other conditions are unnecessary.
@Web-eWorks Web-eWorks merged commit c8f6b39 into pioneerspacesim:master Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants