Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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
2
Question by feanix · Sep 05, 2011 at 09:22 PM · vector3floatprecisiondouble

Vector3 using Doubles Instead of Floats

I'm trying to make a really detailed Solar System simulation. I want vaguely realistic distances between planets but at the same time I want to able to reliably do maths for distances as small as 1km. I've already done a bunch of work on scaling things down and shortening distances but floats just don't give me enough precision to get the distances I want whilst have the same fine control.

Is there a way to use Doubles instead of Floats?

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

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Beugnen · Nov 14, 2012 at 04:03 AM

There are a couple of tricks which seem to be necessary with floats:

Floating Origin
http://wiki.unity3d.com/index.php?title=Floating_Origin http://answers.unity3d.com/questions/137097/scale-objects-based-on-distance.html http://www.floatingorigin.com/

...and logarithmic depth buffers

http://www.gamasutra.com/view/feature/2984/a_realtime_procedural_universe_.php

It's not perfect as Sean O'Neil says.

A better approach may be to use Floating Origin together with scaled-subspaces as per this article

http://forum.kerbalspaceprogram.com/entry.php/54-Scaled-Space-Now-with-100-more-Floating-Origin!?s=7717bd0c73f8b60f31bec52012314ed4

Comment
Add comment · 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
1

Answer by Eric5h5 · Sep 05, 2011 at 10:38 PM

There's no way to use doubles in Vector3. You can make your own Vector3-like struct that uses doubles, but you won't be able to use it for Transform.position. Generally the way you handle this isn't by using doubles anyway, but by doings things like using two coordinate systems, one "global" and one "local", so you can have precision with close objects using local coords.

Comment
Add comment · Show 6 · 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 feanix · Sep 05, 2011 at 11:31 PM 0
Share

That's a really interesting idea. Would I be able to just add a new coordinate on top of the existing system so that I could use it with transform?

avatar image Eric5h5 · Sep 05, 2011 at 11:34 PM 0
Share

No, you'd have to create a system to handle the two coordinate systems.

avatar image feanix · Sep 06, 2011 at 01:08 AM 0
Share

God, I have no idea where to even start with that. I started thinking along the lines of new new vector3 to act as the new coord system's origin, but then I realised that would require me to reference the original coord system and I'd be back to square one. For this to work I'd have to completely circumvent the entire existing coordinate system and I'm not sure how to reference points in space without it.

avatar image Eric5h5 · Sep 06, 2011 at 01:14 AM 0
Share

There are a bunch of topics on the forums about this, so searching should reveal some info.

avatar image feanix · Sep 06, 2011 at 01:57 AM 0
Share

I went through about 20 pages of results for the keyword "coordinate". I figured anything related to this would have to have that word in there SO$$anonymous$$EWHERE? :P

Anyways, no luck. The only thing I found was this page, and it didn't have much to say about a custom coord system: http://forum.unity3d.com/threads/59476-Problem-simulating-tiny-ships-vs-huge-stations-and-planets?highlight=coordinate

I don't spose you remember any of the topics you were talking about, do you? :(

Show more comments

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.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Convert double to float for Vector3 1 Answer

maximum distance from origin (float precision) 1 Answer

CharacterController.Move precision 1 Answer

Losing float precision when adding to Vector3 1 Answer

Precision problem when moving Rect values 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