7
$\begingroup$

I have two sets of vectors,

(* SET_1:  *)

A0 = {-23.645, 8.761, 19.186};
A1 = {8.909, 11.977, -26.572};
A2 = { 6.098, 8.537, 31.834};
A3 = {9.866, -32.131, -24.569};

(* SET_2:  *)

B0 = {-13.9469, 28.7731, -3.21699};
B1 = {-13.8077, -27.3636, 0.329735};
B2 = {2.94231, 23.5992, 23.8511};
B3 = {24.8123, -25.0087, -20.9639};

These two sets are such that A0 = B0, A1=B1, A2=B2, and A3=B3 (Let's say within experimental error) but only rotated in 3d space. Now is there any way to know the rotation axis and angle of this transformation so that I can use this information for future use.

$\endgroup$
  • 1
    $\begingroup$ Sorry, I didn't get the question: Are you looking for the rotationmatrix R which maps ` A[i]->B[i]: B[i]=R.A[i]`? $\endgroup$ – Ulrich Neumann Jun 8 '18 at 9:56
  • $\begingroup$ @Ulrich..Yes I am looking for single rotation matrix which can transform Set A[i]->B[i] $\endgroup$ – Bikash Jun 8 '18 at 10:05
  • $\begingroup$ By the way, the map you are looking for seems to be a reflection, not a rotation. $\endgroup$ – Ulrich Neumann Jun 11 '18 at 8:41
  • $\begingroup$ It seems like that when we only use TransformationClass -> "Rigid". But if you add Method -> "FindFit", then it looks like in a rotating frame. $\endgroup$ – Bikash Jun 11 '18 at 9:00
  • $\begingroup$ No it's another point: The determinant of the transformation matrix equals -1 which indicates that the transformation is no rotation! $\endgroup$ – Ulrich Neumann Jun 11 '18 at 9:10
7
$\begingroup$

I think you want a single transformation function for all points, rather than one for each point independently as kglr's answer currently shows.

set1 = {A0, A1, A2, A3};
set2 = {B0, B1, B2, B3};

tF2 = FindGeometricTransform[
        set1, set2
         , TransformationClass -> "Rigid"
         , Method -> "FindFit"
      ][[2]];

Graphics3D[{
   {Red, PointSize[Large], Point[set1]},
   {Opacity[.15, Blue], Sphere[tF2@set2, 2]}
}]

enter image description here

$\endgroup$
  • $\begingroup$ Thanks...you got my point!! $\endgroup$ – Bikash Jun 8 '18 at 10:55
  • $\begingroup$ Just one remark: FindGeometricTransformation is a nonlinear map. You have to use the option TransformationClass -> "Rigid" to get correct results $\endgroup$ – Ulrich Neumann Jun 8 '18 at 11:04
  • $\begingroup$ Hi..I was working with this transformation, I guess one should use TransformationClass -> "Similarity"...any comment? $\endgroup$ – Bikash Jun 8 '18 at 13:39
  • $\begingroup$ TransformationClass -> "Similarity" includes scaling beside translation and rotation! $\endgroup$ – Ulrich Neumann Jun 8 '18 at 13:56
  • $\begingroup$ @Ulrich Thank you, I will amend this answer. $\endgroup$ – Mr.Wizard Jun 9 '18 at 8:21
6
$\begingroup$

If you are looking for a map R.A[i]~B[i] ,i,0,1,2,3 : First you have to define the rotationmatrix R

 ϕ = {{0, -φ3, φ2}, {φ3,0,-φ1}, {-φ2, φ1, 0}};
 φ = Simplify[Sqrt[Tr[-ϕ.ϕ/2]]]
 R = IdentityMatrix[3] + Sin[φ]/φ ϕ + (1 - Cos[φ])/φ^2 ϕ.ϕ ;

which depends on φ1, φ2, φ3

Now you can calculate the optimal rotation parameters φ1, φ2, φ3

 J = Total@MapThread[(R.#1 - #2 ).(R.#1 - #2 ) &, {{A0, A1, A2, A3},{B0, B1, B2, B3}}]
 sol=NMinimize[J, {φ1, φ2, φ3}]
 (* {2061.5, {φ1 -> -1.01538, φ2 ->1.45343, φ3 -> 1.3975}} *)

The optimal rotationmatrix is

Ropt=R /.sol[[2]]     
(*{{-0.303462, -0.951876, 0.0429177}, 
{0.00554758, 0.043276,0.999048}, 
{-0.952827, 0.303411, -0.007852}} *)

Ropt.Transpose[Ropt] (*test:  should be identitymatrix[3] *)
$\endgroup$
  • $\begingroup$ Thank you very much!! $\endgroup$ – Bikash Jun 8 '18 at 11:24
4
$\begingroup$

You can use FindGeometricTransform:

tFs = MapThread[FindGeometricTransform[{#}, {#2}][[2]] &,
  {{A0, A1, A2, A3}, {B0, B1, B2, B3}}]; 

Graphics3D[{Red, PointSize[Large], Point[{A0, A1, A2, A3}], Opacity[.15, Blue],
  MapThread[Sphere[#@#2, 2] &, {tFs, {B0, B1, B2, B3}}]}]

enter image description here

$\endgroup$
  • $\begingroup$ I interpret this differently; CW below. $\endgroup$ – Mr.Wizard Jun 8 '18 at 10:11
  • $\begingroup$ @Mr.Wizard, good point. That possibility didn't occur to me. $\endgroup$ – kglr Jun 8 '18 at 10:18
  • $\begingroup$ Thank you very much guys $\endgroup$ – Bikash Jun 8 '18 at 11:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.