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 DC3210 · Mar 04, 2017 at 11:47 AM · rotationquaternionmatrix

Quaternion from transition matrix

Hi,

i need to calculate the quaternion from a transition matrix. What i name a transition matrix is the matrix that allow to express the coordinates of a vector in a first referential R1 (x,y,z) with the combinaison of vectors defining a second referential R2 => v2 = M . v1

I know coordinates of 3 points in R1 and the same points in R2, so i can calculate the matrix and it works fine : i can convert coordinates of any point from R1 to R2 and vice versa.

However, i need to convert this matrix in a transform, so in a translation and a rotation (the quaternion i'm searching).

The functions to convert one matrix4x4 to quaternion doesn't work because i think them works for rotation matrix, but here it's a transition matrix.

May be there is another solution from known coordinates of 3 points in two referential to calculate translation and rotation ?

I tryed with 2 successives rotations and even 3 successives rotations, but it's not exact each times : from the 3 points => calculate quaternion q1 to transform v1 to v1', calculate quaternion to transform q1.v2 to v2', and combine the 2 quaternions... and even tryed to do the same with v1,v2,v3...

Any idea please ?

here it's my code to calculate transition matrix : it's 3 équations systems with each 3 unkown variables, so i use matrix to solve each system in 3 times, result is matrix MatR1R2 (or MatR2R1) : (abc) (def) (ghi)

 // résolution du systèmes de 3 x 3 équations à 3 inconnues pour connaitre les coeff de la matrice de passage
 // matrix de passage : |abc0|
 //                                     |def0|
 //                                     |ghi0|
 //                                     |0001|
 
 Matrix4x4 m;
 Vector4 eq1,eq2,eq3;
 Vector4 abc, def, ghi;
 
 // les 3 coeff a,b,c
 eq1 = new Vector4(x2, y2, z2, x5);
 eq2 = new Vector4(x1, y1, z1, x4);
 eq3 = new Vector4(x, y, z, x3);
 m = assignMatrix(eq1, eq2, eq3);
 //Debug.Log("m pour abc =" + m.ToString("F3"));
 abc = solveSystem3(m);
 
 // les 3 coeff d,e,f
 eq1 = new Vector4(x2, y2, z2, y5);
 eq2 = new Vector4(x1, y1, z1, y4);
 eq3 = new Vector4(x, y, z, y3);
 m = assignMatrix(eq1, eq2, eq3);
 //Debug.Log("m pour def =" + m.ToString("F3"));
 def = solveSystem3(m);
 
 // les 3 coeff g,h,i
 eq1 = new Vector4(x2, y2, z2, z5);
 eq2 = new Vector4(x1, y1, z1, z4);
 eq3 = new Vector4(x, y, z, z3);
 m = assignMatrix(eq1, eq2, eq3);
 //Debug.Log("m pour ghi =" + m.ToString("F3"));
 ghi = solveSystem3(m);
 
 //Calcul matrice de passage du nouveau référentiel à l'ancien
 MatR2R1 = assignMatrix(abc, def, ghi);
 
 //Calcul matrice de passage de l'ancien référentiel au nouveau
 MatR1R2 = MatR2R1.inverse;
 
 Debug.Log(MatR1R2.ToString("F3"));
 
 // TEST
 vDelta1 = new Vector4(x2,y2,z2,0.0f);
 vDelta2 = new Vector4(x5, y5, z5, 0.0f);
 Debug.Log("vDelta1 : x=" + vDelta1.x.ToString("F3") + " y=" + vDelta1.y.ToString("F3") + " z=" + vDelta1.z.ToString("F3"));
 Debug.Log("vDelta2 : x=" + vDelta2.x.ToString("F3") + " y=" + vDelta2.y.ToString("F3") + " z=" + vDelta2.z.ToString("F3"));
 vDelta2 = MatR1R2 * vDelta2;
 Debug.Log("MatR1R2 * vDelta2 : x=" + vDelta2.x.ToString("F3") + " y=" + vDelta2.y.ToString("F3") + " z=" + vDelta2.z.ToString("F3"));
 
 The function to solve one system
     Vector4 solveSystem3 (Matrix4x4 system3)
     {
         Vector4 result = Vector3.zero;
         Matrix4x4 m = system3;
         Matrix4x4 m1 = system3;
         Matrix4x4 m2 = system3;
         Matrix4x4 m3 = system3;
         float d = 0.0f;
         float d1 = 0.0f;
         float d2 = 0.0f;
         float d3 = 0.0f;
 
         // on fixe la dernière colone et dernière ligne de chaque matrice
         m.SetColumn(3, new Vector4(0, 0, 0, 1));
         m.SetRow(3, new Vector4(0, 0, 0, 1));
         m1.SetColumn(3, new Vector4(0, 0, 0, 1));
         m1.SetRow(3, new Vector4(0, 0, 0, 1));
         m2.SetColumn(3, new Vector4(0, 0, 0, 1));
         m2.SetRow(3, new Vector4(0, 0, 0, 1));
         m3.SetColumn(3, new Vector4(0, 0, 0, 1));
         m3.SetRow(3, new Vector4(0, 0, 0, 1));
 
         // modifs de colone 0 pour la matrice m1
         m1[0, 0] = system3[0, 3];
         m1[1, 0] = system3[1, 3];
         m1[2, 0] = system3[2, 3];
 
         // modifs de colone 1 pour la matrice m2
         m2[0, 1] = system3[0, 3];
         m2[1, 1] = system3[1, 3];
         m2[2, 1] = system3[2, 3];
 
         // modifs de colone 2 pour la matrice m3
         m3[0, 2] = system3[0, 3];
         m3[1, 2] = system3[1, 3];
         m3[2, 2] = system3[2, 3];
 
         // calcul des déterminants
         d = m.determinant;
         d1 = m1.determinant;
         d2 = m2.determinant;
         d3 = m3.determinant;
 
         // calcul des coefficients résultats a,b,c
         result = new Vector4(d1 / d, d2 / d, d3 / d,0.0f);
 
         return result;
     }
 
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 DC3210 · Mar 04, 2017 at 11:50 AM 0
Share

i forget a code presicion : 3 points known => p3, p4, p5 in R1 => p, p1, p2 in R2

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

105 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

Related Questions

Set orientation from 3x3 rotation matrix 0 Answers

How to limit only one axis rotation? c# 1 Answer

How can I fix rotation of Z axis to 0? 0 Answers

How to make a 2D sprite rotate towards a specific point while facing perpendicular to the camera ? 1 Answer

Simple Quaternion.FromToRotation example please 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