• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by trevk84 · Mar 10, 2018 at 07:15 AM · trajectory

Trajectory line without floating point error

I'm trying to draw an orbit line of a space ship around a planet using lineRenderer. I'm not using Unity physics, but rather my own, making it easier for me to predict/simulate paths/orbits. The problem I'm having, as far as I am aware, has to do with floating point inaccuracies. Because my ship is small, and my planet is obviously huge in comparison, an insignificant error value near the start of my trajectory line "dominoes" down the line causing a randomly, significant error in destination. The math is correct because I use the same fiction to move my ship as I do to simulate where it is going. So my question is, what is the common way of making a trajectory line that requires long distances and high precision?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Mar 10, 2018 at 12:56 PM

I'm not using Unity physics, but rather my own

Well that means "your own" way is the problem. floating point math is 100% deterministic. If there are any differences between two runs it depends on you using not the same input. The most common issue is deltaTime which is never the same between two runs. It's not clear what exactly you are simulating. However you should keep in mind that deltaTime can only compensate linear changes over time. Any non linear change can't be simply scaled by deltaTime. To get the best fit for quadratic changes (i.e. constant acceleration --> linear velocity change --> quadratic position change) is to apply half the old velocity and half of the new velocity.


However any other non-linear motion can't be simply "fixed" like that. That means if you apply changing forces (not constant like Newton's gravity) the resulting velocity won't be changed linearly and the resulting motion would not be linear either.


That's the main reason why most physics systems work with a constant deltaTime value to ensure the same results, even they are not "correct". However to correctly simulate gravity with a time discrete simulation can be quite tricky since calculating correct time discrete values highly depends on the derivatives of all involved formulas. That's a main problem with time discrete simulations as they usually assume the system does not change in between time steps, only exactly at each step. However most processes in physics are continous. So you would need the limit of your calculations with deltaTime goes towards 0.


For reference an SO question about that problem

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image trevk84 · Mar 10, 2018 at 05:27 PM 0
Share

You are 100% correct. DeltaTime was the variable I wasn't considering. Thank you for the thorough explanation.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

75 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Setting limits to my trajectory 2 Answers

trajectory of ball 0 Answers

Bezier curve that update in real time. 1 Answer

Help with SlingShot trajectory... 1 Answer

Calculate a trajectory in all possible directions (2D). 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges