Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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
0
Question by ariansyah · Dec 10, 2014 at 02:31 AM · inversetransformpoint

InverseTransformPoint not equal to the position in World to Local Matrix?

Hi All,

I'd like to ask how the inverseTransformPoint works. Suppose I have a gameobject with position (33.0, 25.0, 20.0) and the same orientation w.r.t world coordinates (with the scale 1). Then, the position of world coordinates w.r.t to the local coordinates of my gameobject would be (-33.0, -25.0,-20.0).

But, when I do the InverseTransformPoint to the position of my gameObject, the position of World to local are totally different from World To Local Matrix.

does anyone know what is the difference?

Thanks in advance

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
1
Best Answer

Answer by Owen-Reynolds · Dec 10, 2014 at 06:01 AM

You're probably using the matrix incorrectly. But figure the correct value, and see who's wrong and right.

Take your object p1 at (33,25,20). For simplicity, keep it "unspun" facing +Z. If you have point p2 at z+1 -- (33,25,21) -- then InvTransPoint should give you (0,0,1). Just to be clear, it's saying that p2 is one unit in front of p1. If you spin p1 to face right, then InvTransPoint should give you (-1,0,0). Again, to be clear, it's now saying that p2 is just to p1's left.

Try it again with the worldToLocal matrix. Should give the same numbers.

Comment
Add comment · Show 3 · 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 ariansyah · Dec 10, 2014 at 11:44 AM 0
Share

Hi Owen, thank you very much for your feedback. I understood the example you provided. But, suppose if a camera in world coord (33,25,20). I'd like to find the position of world coord w.r.t camera.

 var cam = Camera.main.transform;
 
 var Wtocam = transform.InverseTransformPoint(Vector3(cam.position.x, cam.position.y, cam.position.z));
 

As far as I understand, the Wtocam must be (-33,-25,-20). But the returned value from InvTrsPoint is completely different. Do you know what's the problem here?

Thanks

avatar image Owen-Reynolds · Dec 10, 2014 at 02:20 PM 0
Share

?? That second line gives how to go from the player (if the script is on the player) to the camera in the player's local coords. That what InvTransPoint does. If figures out local coords.

To get world coords from player to camera, just use transform.position - camera.position. If the player has no extra rotation, they will be the same.

Local vs. World is a slippery concept. Helps to draw pictures, and focus on the end result.

avatar image ariansyah · Dec 11, 2014 at 11:05 AM 0
Share

that's right.

 var pos= transform.InverseTransformPoint(transform.position);

I've tried doing the InvTransPoint to the position of object itself (in WCS) to see if I'll get the pos of World coordinate w.r.t to the local coordinates of the object. But it turns out zero numbers. This result due to the multiplication of Inverse matrix to the matrix itself is zero.

Thank you Owen for your time for giving this 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.

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Gross "Almost zero" Vector components when adjusting to local space and custom handles 2 Answers

Can't convert Bounds from world coordinates to local coordinates 6 Answers

rectTransform.InverseTransformPoint(rectTransform.position) is non-zero? 0 Answers

rotating a game object relevant to the face it on, on another game object 0 Answers

TransformPoint returns wrong points? 1 Answer


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