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
0
Question by Michael_R · Dec 05, 2019 at 07:37 PM · rotaterotatearoundmatrix

XYZ Rotation Matrix

Hello,

can somone tell me which lines are missing for a complete xyz rotation matrix?

 x = Mathf.Cos(Radians) * Child.transform.localPosition.x - Mathf.Sin(Radians) * Child.localPosition.y;
 y = Mathf.Sin(Radians) * Child.transform.localPosition.x + Mathf.Cos(Radians) * Child.localPosition.y;

Example video of current state: https://www.youtube.com/watch?v=P3N3gYSOwVU&feature=youtu.be

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 · Dec 05, 2019 at 10:26 PM

I'm not really sure what you're asking here. First of all you don't have a matrix here. You just carry out a single axis / plane rotation manually. There is nothing like a "complete xyz rotation matrix". First of all if you asking for how to create a combined rotation matrix which rotates around 3 axis (in 3 planes) using euler angles, there are many different ways how you could combine those rotations. The result would be completely different.


If you are interested in how Unity's eulerangles and rotation matrices look like, see my answer over here. If you have trouble understandinf matrices in the first place, you might want to have a look at my Matrix crash course.


You haven't said what you actually want to achieve. Why do you translate the local position of your child object manually?

Comment
Add comment · Show 2 · 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 Bunny83 · Dec 06, 2019 at 12:05 AM 0
Share

The combined rotation matrix for all 3 eulerangles is quite complex. I still don't see any reason why you want to do this manually since Untiy provides us with the $$anonymous$$atrix4x4 struct and also with the Quaternion struct. However If you really want to know how Unity's euler angles rotation matrix looks like. Have a look at this:

 sx = sin(Xrad);   cx = cos(Xrad);
 sy = sin(Yrad);   cy = cos(Yrad);
 sz = sin(Zrad);   cz = cos(Zrad);
   
   Y * X * Z
   
 [ cy, 0, sy]   [1,  0,  0]   [cz,-sz, 0]
 [  0, 1,  0] * [0, cx,-sx] * [sz, cz, 0]
 [-sy, 0, cy]   [0, sx, cx]   [ 0,  0, 1]
 
 [ cy, sx*sy, sy*cx]          [cz,-sz, 0]
 [  0, cx   ,-sx   ]        * [sz, cz, 0]
 [-sy, sx*cy, cx*cy]          [ 0,  0, 1]
 
 [ cy*cz + sx*sy*sz,-cy*sz + sx*sy*cz, sy*cx]
 [ cx*sz           , cx*cz           ,-sx   ]
 [-sy*cz + sx*cy*sz, sy*sz + sx*cy*cz, cx*cy]
 
 nx = ox*( cy*cz + sx*sy*sz) - oy*(cy*sz + sx*sy*cz) + oz*(sy*cx);
 ny = ox*( cx*sz           ) + oy*(cx*cz           ) - oz*(sx);
 nz = ox*(-sy*cz + sx*cy*sz) + oy*(sy*sz + sx*cy*cz) + oz*(cx*cy);

I've included the intermediate steps of combining the 3 rotation matrices into one. (ox,oy,oz) is the original vector while (nx,ny,nz) is the rotated vector.

avatar image Michael_R Bunny83 · Dec 06, 2019 at 09:32 PM 0
Share

Thanks for your answer @Bunny83 . You know I am just a bit curious about I$$anonymous$$ especially the 6 DOF Arm from $$anonymous$$uka with spherical wrist atm and I don't want to use libraries.

So I've watched your TRS $$anonymous$$atrix functions but I don't know how to use them to rotate my child object localPosition in the video

Thats the link for your functions id like to rotate my child object: https://answers.unity.com/questions/1435216/are-these-rotation-matrices-right.html

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

121 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

Related Questions

RotateAround() faster than rotate 1 Answer

rotate around character 1 Answer

Rotate Around Object 2 Answers

How to rotate an object according to the camera's view? 1 Answer

rotation script in unity 3 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