Message Boards Message Boards

0
|
1935 Views
|
11 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Determine the mirror reflection between the coordinates of a pire of points

Posted 1 year ago

Let's consider the inverse of the following question:

In[1]:= ReflectionTransform[{1, 2, 3, 0}] // TransformationMatrix;
% . {x, y, z, t, 1}

Out[2]= {(6 x)/7 - (2 y)/7 - (3 z)/7, -((2 x)/7) + (3 y)/7 - (6 z)/
  7, -((3 x)/7) - (6 y)/7 - (2 z)/7, t, 1}

E.g., I've the following two points:

A = {x, y, z, t}
B = {(6 x)/7 - (2 y)/7 - (3 z)/7, -((2 x)/7) + (3 y)/7 - (6 z)/
    7, -((3 x)/7) - (6 y)/7 - (2 z)/7, t}

Now, how can I determine whether they are connected by the mirror reflection relationship and also find the corresponding transform matrix between them. Any tips will be appreciated.

Regards, Zhao

POSTED BY: Hongyi Zhao
11 Replies

" Obviously FindGeometricTransform yields a unit matrix for all n>=8."

This means that it the algorithm is producing nonsense even for small exact image pairs.

The procedure seems to be buggy in other aspects, too.

https://mathematica.stackexchange.com/questions/232750/findgeometrictransform-not-working-properly-for-a-simple-problem

POSTED BY: Roland Franzius
Posted 1 year ago

Thank you for pointing this out. As a built-in function, it is really regrettable to have such problems.

POSTED BY: Hongyi Zhao

Replace Det by MatrixForm and you observe that FindGeometricTransform is obviously giving a unit matrix for n>=8.

By the way only the homogenous matrix with both right and bottom margins removed has to have det =-1 for a reflection at a hyperplane.

POSTED BY: Roland Franzius
Posted 1 year ago

Replace Det by MatrixForm and you observe that FindGeometricTransform is obviously giving a unit matrix for n>=8.

Yes. You are right, as shown below:

n = 8;
PointSet = Partition[RandomReal[{-25, 25}, n 7], n];
ReflectedSet = 
  ReflectionTransform[r1 = RandomReal[{-5, 5}, n], 
    r2 = RandomReal[{-5, 5}, n]][
   Permute[PointSet, RandomPermutation[Length[PointSet]]]];
FindGeometricTransform[PointSet, ReflectedSet] // Last // 
  TransformationMatrix // MatrixForm

enter image description here

By the way only the homogenous matrix with right an bottom margins removed has to have det=-1 for a reflection.

I still can't understand your above description. If I remove the right and bottom parts, there will be an 8 by 8 identity matrix left. So, I still don't know to have det=-1 for a reflection.

POSTED BY: Hongyi Zhao
Posted 1 year ago

Now, I try to further check your example code as follows:

In[101]:= n = 8;
PointSet = Partition[RandomReal[{-25, 25}, n 7], n];
ReflectedSet = 
  ReflectionTransform[r1 = RandomReal[{-5, 5}, n], 
    r2 = RandomReal[{-5, 5}, n]][
   Permute[PointSet, RandomPermutation[Length[PointSet]]]];
FindGeometricTransform[PointSet, ReflectedSet] // Last // 
  TransformationMatrix // Det

Out[104]= 1.

As we all know, a mirror reflection transformation must correspond to the matrix whose determinant is -1, which is inconsistent with the above result. Therefore, I am still puzzled by your approach. Any more hints will be appreciated.

Regards, Zhao

POSTED BY: Hongyi Zhao

Hi Hongyi, the reconstruction - if possible - is very easy: Build the mirror tranformation of the two centers of gravity.

Example:

Generate a random set of 3- vectors

In[104]:= 
PointSet = Partition[RandomReal[{-25, 25}, 15], 3]

Out[104]= {{14.2719, 17.0303, -20.0201}, {12.5764, 
  8.93466, -9.76079}, {7.09157, -0.257111, -11.4155}, {-13.973, -10.1625, 
  16.7584}, {-24.9073, 12.8249, -21.4149}}

In[105]:= center1 = Total[PointSet]/Length[PointSet]

Out[105]= {-0.988086, 5.67406, -9.17058}

and its reflected set by a random ReflectionTransform with parameter vectors x,y. We permute the list

In[106]:= ReflectedSet = 
 ReflectionTransform[r1 = RandomReal[{-5, 5}, 3], 
   r2 = RandomReal[{-5, 5}, 3]][
  Permute[PointSet, RandomPermutation[Length[PointSet]]]]

Out[106]= {{10.7141, -4.64109, -0.747376}, {24.9125, 4.153, 11.3158}, {-23.62, 
  1.51238, -11.6515}, {16.3365, 4.38416, 1.3125}, {-7.40725, -8.35364, 
  30.1216}}

In[108]:= center2 = Total[ReflectedSet]/Length[ReflectedSet]

Out[108]= {4.18717, -0.589039, 6.0702}

mid = (center1 + center2)/2

Out[109]= {1.59954, 2.54251, -1.55019}

In[110]:= dir = center2 - center1

Out[110]= {5.17526, -6.2631, 15.2408}

In[113]:= ReflectionTransform[dir, mid] // InputForm

Out[113]//InputForm=
TransformationFunction[{{0.8204215036351963, 0.21732585248810143, -0.5288459418519571, -1.0851217264811106}, 
 {0.21732585248810143, 0.7369923063408783, 0.6400092298042841, 1.3132140486453467}, {-0.5288459418519571, 0.6400092298042841, 
 -0.5574138099760739, -3.195606562487054}, {0., 0., 0., 1.}}]

In[114]:= ReflectionTransform[r1, r2] // InputForm

Out[114]//InputForm=
TransformationFunction[{{0.8204215036351961, 0.21732585248810155, -0.5288459418519573, -1.0851217264811104}, 
 {0.21732585248810155, 0.7369923063408781, 0.6400092298042842, 1.3132140486453467}, {-0.5288459418519573, 0.6400092298042842, 
 -0.5574138099760744, -3.195606562487054}, {0., 0., 0., 1.}}]

In[115]:= % == %%

Out[115]= True

Regards Roland

POSTED BY: Roland Franzius
Posted 1 year ago

Thanks a lot for your nice example. I tried as follows but failed:

In[342]:= n = 8;
PointSet = Partition[RandomReal[{-25, 25}, 15], n];
center1 = Total[PointSet]/Length[PointSet];
ReflectedSet = 
  ReflectionTransform[r1 = RandomReal[{-5, 5}, n], 
    r2 = RandomReal[{-5, 5}, n]][
   Permute[PointSet, RandomPermutation[Length[PointSet]]]];
center2 = Total[ReflectedSet]/Length[ReflectedSet];
 mid = (center1 + center2)/2;
dir = center2 - center1;

ReflectionTransform[dir, mid] // TransformationMatrix // InputForm
ReflectionTransform[r1, r2] // TransformationMatrix // InputForm
% == %%
Out[351]= False
{{0.5099503864003545, 0.18538145813340623, -0.02469833515332397, -0.01995727838866815, -0.04645357867574137, -0.3024036518959173, -0.6739143575470887, 
0.39599185939935283, -2.1655063144913793}, {0.18538145813340623, 0.9298718250847475, 0.009343162931113624, 0.007549662861459084, 0.017572980186980138, 
0.11439664143706756, 0.25493587341379215, -0.14980023709269571, 0.8191919900287443}, {-0.02469833515332397, 0.009343162931113624, 0.9987552122429704, 
-0.0010058400960075197, -0.0023412446890369175, -0.015241042006445287, -0.033965056201295286, 0.019957856082350425, -0.1091407874788013}, {-0.01995727838866815, 
0.007549662861459084, -0.0010058400960075197, 0.9991872395169192, -0.0018918227380525364, -0.012315393582918402, -0.027445173040531144, 0.016126774837405846, 
-0.08819027945613422}, {-0.04645357867574137, 0.017572980186980138, -0.0023412446890369175, -0.0018918227380525364, 0.99559649694256, -0.028665937989403326, 
-0.06388278402888639, 0.037537503316121906, -0.20527619073937942}, {-0.3024036518959173, 0.11439664143706756, -0.015241042006445287, -0.012315393582918402, 
-0.028665937989403326, 0.8133903871319097, -0.4158643474695681, 0.2443617566062408, -1.3363075891349618}, {-0.6739143575470887, 0.25493587341379215, 
-0.033965056201295286, -0.027445173040531144, -0.06388278402888639, -0.4158643474695681, 0.0732355485966375, 0.5445664930959656, -2.9779960154950267}, 
{0.39599185939935283, -0.14980023709269571, 0.019957856082350425, 0.016126774837405846, 0.037537503316121906, 0.2443617566062408, 0.5445664930959656, 
0.6800129040839014, 1.7498694993708317}, {0., 0., 0., 0., 0., 0., 0., 0., 1.}}
POSTED BY: Hongyi Zhao

I expected that, because for my example one does not expect a "True".

As everybody should know, two equal Reals are never Equal really.

You have to check the Norm of the difference of the transformation matrices against a small error.

POSTED BY: Roland Franzius
Posted 1 year ago

Thank you for pointing this out. But I'm not sure if you mean the following method, aka, the maximum singular values based comparison:

In[1007]:= n = 8;
PointSet = Partition[RandomReal[{-25, 25}, 15], n];
center1 = Total[PointSet]/Length[PointSet];
ReflectedSet = 
  ReflectionTransform[r1 = RandomReal[{-5, 5}, n], 
    r2 = RandomReal[{-5, 5}, n]][
   Permute[PointSet, RandomPermutation[Length[PointSet]]]];
center2 = Total[ReflectedSet]/Length[ReflectedSet];
 mid = (center1 + center2)/2;
dir = center2 - center1;
m1 = (ReflectionTransform[dir, mid] // TransformationMatrix);
m2 = (ReflectionTransform[r1, r2] // TransformationMatrix);
m1 // Norm // NumberForm[#, 50] &
m2 // Norm // NumberForm[#, 50] &
% == %%
m1 // SingularValueList // Max
m2 // SingularValueList // Max

(m1 // SingularValueDecomposition)[[2]]
(m2 // SingularValueDecomposition)[[2]]

Out[1016]//NumberForm= \!\(
TagBox[
InterpretationBox[
StyleBox["\<\"9.39454965386593\"\>",
ShowStringCharacters->False],
9.394549653865932,
AutoDelete->True],
NumberForm[#, 50]& ]\)

Out[1017]//NumberForm= \!\(
TagBox[
InterpretationBox[
StyleBox["\<\"9.39454965386593\"\>",
ShowStringCharacters->False],
9.394549653865932,
AutoDelete->True],
NumberForm[#, 50]& ]\)

Out[1018]= True

Out[1019]= 9.39455

Out[1020]= 9.39455

Out[1021]= {{9.39455, 0., 0., 0., 0., 0., 0., 0., 0.}, {0., 1., 0., 
  0., 0., 0., 0., 0., 0.}, {0., 0., 1., 0., 0., 0., 0., 0., 0.}, {0., 
  0., 0., 1., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 1., 0., 0., 0., 
  0.}, {0., 0., 0., 0., 0., 1., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., 
  1., 0., 0.}, {0., 0., 0., 0., 0., 0., 0., 1., 0.}, {0., 0., 0., 0., 
  0., 0., 0., 0., 0.106445}}

Out[1022]= {{9.39455, 0., 0., 0., 0., 0., 0., 0., 0.}, {0., 1., 0., 
  0., 0., 0., 0., 0., 0.}, {0., 0., 1., 0., 0., 0., 0., 0., 0.}, {0., 
  0., 0., 1., 0., 0., 0., 0., 0.}, {0., 0., 0., 0., 1., 0., 0., 0., 
  0.}, {0., 0., 0., 0., 0., 1., 0., 0., 0.}, {0., 0., 0., 0., 0., 0., 
  1., 0., 0.}, {0., 0., 0., 0., 0., 0., 0., 1., 0.}, {0., 0., 0., 0., 
  0., 0., 0., 0., 0.106445}}
POSTED BY: Hongyi Zhao
Posted 1 year ago

Thank you very much for your ideas and explanations. However, it would be better if we had a concrete example to show the above algorithm. It seems too abstract for me to implement an algorithm based solely on the above description.

Regards, Zhao

POSTED BY: Hongyi Zhao

Hi Hongyi,

the programming idea could be to follow path:

A nessecary conditon for two sets of points to be images of each other under the euclidean group is the equality of the sets of all pair distances. If all distances are different, the pairs can be ordered in both sets and the pairs wirh the same index are possible images of each other. The question is, if all images are produced by the same transformation.

For each mirror pair of four points there are two possible joining lines and two corresponding mirror hyperplanes though their midpoints. The set of these pairs of hyperplanes has to contain the same hyperplane for each mirror pair of pairs.

Regards Roland

POSTED BY: Roland Franzius
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract