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
3
Question by Cery_ · Jul 09, 2020 at 08:57 AM · transformquaternionpose

Usage of Pose.GetTransformedBy

Hi, I ran into an issue using Pose.GetTransformedBy.

The documentation is pretty brief on this one:

"Transforms the current pose into the local space of the provided pose."

I wanted to use this to convert a pose from worldspace into the space of another pose. But it seems like this is not how it works. Here is my test setup: I have a root object. I have child object A on the root with an offset and rotation. If i take the global pose of the child object and call get transformed by the root, I should get the local Pose of child object A.

Example code to try is below.

My Question:
How is GetTransformedBy usually used? Did i missunderstand the documentation?

My current solution is to transform the Pose via this code:

 public static Pose worldPoseToLocal(Pose worldPose, Transform system)
 {
     return new Pose(system.InverseTransformPoint(worldPose.position),
         Quaternion.Inverse(system.rotation) * worldPose.rotation);
 }

Code to test GetTransformedBy:

 GameObject root = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
 root.name = "root";
 GameObject aobj = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
 aobj.name = "A";
 GameObject bobj = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
 bobj.name = "B";
 
 //Random pose
 root.transform.position = new Vector3(1.0f, 0.5f, 1.2f);
 root.transform.rotation = new Quaternion(0.2f, 1.2f, 0.2f, 1.0f).normalized;
 
 //Random child Pose
 aobj.transform.SetParent(root.transform);
 aobj.transform.localPosition = new Vector3(2.5f, 1.0f, 3.0f);
 aobj.transform.localRotation = new Quaternion(0.8f, 0.0f, 1.2f, 0.77f).normalized;
 
 Pose relPose = new Pose(aobj.transform.position, aobj.transform.rotation).GetTransformedBy(root.transform);
 
 // Visualise pose difference
 // relPose != aobj.localPosition, aobj.localRotation
 bobj.transform.SetParent(root.transform);
 bobj.transform.localPosition = relPose.position;
 bobj.transform.localRotation = relPose.rotation;
Comment
Add comment · Show 1
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 elaidlaw · Sep 11, 2020 at 09:34 PM 0
Share

Did you ever figure out what GetTransformedBy is actually doing?

0 Replies

· Add your reply
  • Sort: 

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

170 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Use a single rotation axis of a freely rotating object 1 Answer

Rotation Jumping values (0 to 180) 1 Answer

Problem with Quaternion.Euler() when rotating object 3 Answers

Transform/Quaternion affecting collider? 1 Answer

Make an object rotate instantly upon an event occuring in C# 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