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 /
  • Help Room /
avatar image
0
Question by FChavez509 · Jul 30, 2018 at 11:00 PM · programmingmath

How to convert between local and parent?

There's been multiple times where I've needed to convert coordinates and axis from a Game-Object's Local-Space to their parent Game-Object's Local-Space. At the moment, I do this by first converting said data to World-Space, which feels wasteful.


Shouldn't there be a way to convert something from Local-Space to Parent-Space? When you stop to think about it, the conversion of Local-Space to World-Space has to go through Parent-Space first. Why can't we stop it right there? Can we stop it right there? It feels like I'm taking two steps forward and one step back just to get to where I want to go.


I suspect that I could do something with the conversion matrices of the two objects to create a single matrix that can be applied to multiple points, but even then, I'm first going though World-Space. Also, we're dealing with floats here, so precision goes down the drain really fast once you start doing compound multiplications.

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

Answer by elenzil · Jul 31, 2018 at 06:36 PM

As you suggested, you could compose the two matrices of child.localToWorldMatrix and parent.worldToLocalMatrix into a single matrix and then multiply that matrix times all your points. I wouldn't worry about loss of precision with just two matrices involved. You've got to have a lot of floating point operations before that becomes an issue, and they have to be cumulative. ie, where the output of one is the input to the next, in a chain several hundred or thousand operations long.

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 FChavez509 · Jul 31, 2018 at 11:49 PM 0
Share

Yeah, I was worried that might be the case. Although, the change in space isn't the only calculation I'm running, it's just one of the first calculations done for the sake of getting everything within the same coordinate system, and I'm not doing the math in World-Space because the scale, rotation, and location of the root object is important.


While the error from this one step is of no consequence on it's own, it does add to the overall error. I have managed to cut down number of calculations done along the chain of calculations over the months, and the current error only becomes visible when dealing with very large distances. And the error is so small that it shouldn't be visible in the final result when viewed on a monitor. But, it just feels like this is one step that shouldn't be needed.


This is only an assumption, but my assumption is that in order to get a matrix to go from local space to world space, you need to apply parent, grand-parent, etc. matrices to create it. It just feels wasteful when all we really need is the first of those mentioned matrices. If feels even worse when the parent coordinate system has multiple children.


There are still other items of higher importance that need work on the framework I'm working on, but this is one of those things in the back of my had that just bothers me.

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

164 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 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 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

Making joint aim in the same direction as the main camera, regardless of joint axis 0 Answers

How could I find out if an objects vector3 hits between 2 points without raycasting in a 3D game? 1 Answer

Modifying number based on % change 0 Answers

Getting average value of slider while playing. 0 Answers

How to get an object to turn to point to a direction using the shortest path. E.g. 15° to 345° in 30° instead of 330°. 0 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