Hongyi Zhao on Mon, 13 Mar 2023 01:00:30 +0100 |
[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]
Re: Determine the mirror reflection relationship between the coordinates of two sets of pairs of points in n-dimension space. |
On Mon, Mar 13, 2023 at 2:38 AM Karim Belabas <Karim.Belabas@math.u-bordeaux.fr> wrote: > > Unordered sets of points then. Very good, your general assumption above will make your algorithm applicable to any case of two sets of points : ordered or disordered correspondence between two sets of points. > OK, so for all (a,b) with a in A and b in B, > compute v = a - b: this gives us the possible (unnormalized, i.e. > arbitrary norm instead of |v| = 1) vectors v(a,b). > > If we normalize them, the possible vectors v are the ones that occur at > least #A times from the (#A)^2 pairs (a,b). It should be a very short > list, with at most #A entries in any case. We can then check whether any > of the attached reflexions s work or not by computing s(A) and comparing > with B (as sets). > > Something like > > normalize(v) = foreach(v, x, if (x, return(v / x))); > > V = matreduce([normalize(a - b) | a <- A; b <-B]); > for (i = 1, #V[,2], if (V[i,2] >= #A, print(V[i,1]))) > > This prints the single vector > v = [0, 1, -1/2, 2, 3/2, 2, -1/2, -1]~ > with attached reflexion > s(x) = x - 2 * (x~*v / norml2(v)) * v; > > Unless I made a stupid mistake, it doesn't work: > ? Set([s(a) | a <- A]) == Set(Vec(B)) > %10 = 0 Failed as follows: ? A=[6,23,-5,25,22,16,25,-4,-22,4,-20,13,10,-7,9,2,19,24,0,-14;0,15,-1,-15,4,0,1,7,4,-15,11,-11,-12,-3,-19,-6,10,13,-2,6;23,3,-22,12,10,3,24,21,-20,23,6,24,10,-9,4,20,5,18,-24,16;17,-6,-15,18,10,-10,-2,2,8,-7,-24,13,7,-10,-21,-13,9,-1,24,14;25,24,-19,-12,-16,-15,5,17,23,-10,25,3,-15,24,25,10,8,7,-5,-24;21,-22,14,0,-10,-21,-5,8,9,-8,7,2,-2,-21,-15,-13,16,-4,-21,15;22,-15,-4,-8,7,-2,11,-9,-6,-7,1,23,-25,-22,9,20,18,17,4,9;17,-23,11,0,-15,-18,-21,8,-14,17,2,17,-9,21,-17,25,-13,-9,17,14]; ? B=[-7,6,9,13,-20,22,25,4,0,-14,19,24,2,25,-5,16,10,23,-4,-22;103/51,-12,-215/17,-445/51,469/51,292/51,47/51,-35/17,-38/51,274/51,-98/51,201/17,126/17,-793/51,55/17,172/17,-568/51,553/51,29/51,-12;-587/51,29,14/17,1166/51,352/51,466/51,1226/51,281/17,-1256/51,832/51,559/51,316/17,226/17,626/51,-410/17,-35/17,488/51,259/51,1235/51,-12;2/51,-7,-141/17,895/51,-1408/51,686/51,-110/51,321/17,1352/51,650/51,-757/51,-57/17,235/17,862/51,-111/17,174/17,445/51,-730/51,-554/51,-24;536/17,7,587/17,109/17,379/17,-228/17,83/17,160/17,-53/17,-424/17,-168/17,89/17,512/17,-218/17,-215/17,3/17,-233/17,302/17,125/17,-1;-559/51,-3,-39/17,334/51,173/51,-334/51,-263/51,304/17,-943/51,701/51,-400/51,-108/17,235/17,-56/51,382/17,-13/17,-14/51,-1546/51,-248/51,-23;-1250/51,28,99/17,1115/51,97/51,313/51,563/51,-229/17,172/51,475/51,1222/51,299/17,226/17,-394/51,-104/17,-120/17,-1297/51,-659/51,-295/51,2;815/51,29,-397/17,751/51,194/51,-853/51,-1067/51,69/17,803/51,746/51,-55/51,-133/17,197/17,28/51,115/17,-478/17,-503/51,-961/51,736/51,2]; ? normalize(v) = foreach(v, x, if (x, return(v / x))); ? V = matreduce([normalize(a - b) | a <- A; b <-B]); ? for (i = 1, #V[,2], if (V[i,2] >= #A, print(V[i,1]))) [0, 1, -1/2, 2, 3/2, 2, -1/2, -1]~ ? s(x) = x - 2 * (x~*v / norml2(v)) * v; ? Set([s(a) | a <- A]) == Set(Vec(B)) *** at top-level: Set([s(a)|a<-A])==Set(Vec(B)) *** ^------------------------ *** in function s: x-2*(x~*v/norml2(v))*v *** ^--------------------- *** _-_: forbidden addition t_VEC (8 elts) + t_COL (8 elts). *** Break loop: type 'break' to go back to GP prompt break> > (Please double-check, this is really a quick hack :-) Side remark: In fact, the point sets used here are generated with Wolfram language, which ensure that they are mirror images of the other via the following commands: In[108]:= n = 8; PointSet = Partition[RandomInteger[{-25, 25}, n 20], n]; ReflectedSet = ReflectionTransform[r1 = RandomInteger[{-5, 5}, n], r2 = RandomInteger[{-5, 5}, n]][ Permute[PointSet, RandomPermutation[Length[PointSet]]]]; A = PointSet // Transpose // ToString // StringReplace[#, {"{{" -> "[", "}}" -> "]", "}, {" -> "; "}] & B = ReflectedSet // Transpose // ToString[#, InputForm] & // StringReplace[#, {"{{" -> "[", "}}" -> "]", "}, {" -> "; "}] & Out[111]= "[-17, 11, 1, 10, 16, 18, 20, 5, -25, -10, 17, -20, 20, 13, \ 7, 14, -10, 12, 1, -7; -20, 3, -25, -13, -1, 17, -23, -22, -6, 1, \ -25, -14, 7, 18, 17, 13, -24, -18, -23, 20; -18, 5, 19, 5, 21, 25, 1, \ 12, -25, -19, 5, 17, -3, -4, -2, -6, 16, 19, -3, 9; -7, 10, -24, 10, \ -3, -10, -2, -11, 3, 7, -10, 12, -15, -15, -5, 21, -13, -8, 21, -19; \ 11, -17, -9, -11, -5, -5, -14, -2, -10, -8, 6, 16, 5, 13, 19, 5, 8, \ 7, 16, -10; 22, 4, 21, 13, 9, 21, 24, -14, 2, -6, -14, -13, -24, 23, \ 3, -9, -16, 13, -20, 22; -16, -24, 3, 7, -20, -18, 0, -19, -6, 21, \ -4, 14, 5, -24, 6, -14, -6, 1, -25, -19; -16, -23, -25, 22, 19, 25, \ -3, 12, 15, 10, 4, 18, 10, 9, -20, -7, -2, 24, 8, -22]" Out[112]= "[5/12, 223/12, -67/3, 40/3, 295/12, -20, 11, 32/3, 7/3, \ 245/12, -65/6, 157/6, 57/4, 59/2, 44/3, -361/12, 275/12, -113/12, \ 283/12, 55/6; -557/18, 257/18, -112/9, -203/9, -733/18, 23/3, 15, \ -154/9, -71/9, -419/18, -217/9, -64/9, 73/6, 28/3, 95/9, -47/18, \ -101/18, -289/18, -7/18, -223/9; -49/36, -479/36, 188/9, 100/9, \ -731/36, -7/3, -1, 191/9, 160/9, 11/36, -509/18, -365/18, -169/12, \ 35/6, 53/9, -595/36, 341/36, 517/36, -1511/36, 91/18; -31/12, \ -113/12, 29/3, -41/3, -5/12, -3, 18, -28/3, 7/3, -19/12, -5/6, 151/6, \ 9/4, 3/2, -61/3, -25/12, 47/12, 127/12, 139/12, -41/6; 269/18, \ 301/18, 130/9, 32/9, 121/18, -44/3, 3, 55/9, -145/9, -247/18, 136/9, \ -62/9, 143/6, 8/3, 13/9, -241/18, -7/18, 163/18, 187/18, 7/9; \ -701/36, 761/36, -110/9, -115/9, 473/36, -8/3, -8, 121/9, 140/9, \ 859/36, 359/18, -19/18, 7/12, 103/6, -200/9, 133/36, 241/36, -595/36, \ 425/36, -277/18; 17/18, -365/18, 112/9, -58/9, 337/18, 43/3, -16, \ 1/9, 17/9, 5/18, -107/9, -125/9, 65/6, -31/3, 13/9, -169/18, -277/18, \ -575/18, 25/18, -146/9; 107/9, 148/9, 134/9, -8/9, 58/9, -10/3, -11, \ 200/9, 106/9, -22/9, -70/9, -25/9, -31/3, 121/3, 26/9, 74/9, 254/9, \ -53/9, 169/9, 158/9]" As a result, the mirror relationship between them is necessarily exist, therefore, the appropriate reflection transformation between them must be found/determined. Therefore, if we can't find an appropriate reflection transformation that connects A and B, there must be a problem with the used algorithm. > Cheers, > > K.B. Best, Zhao > * Hongyi Zhao [2023-03-12 02:06]: > > On Sat, Mar 11, 2023 at 11:32 PM Karim Belabas > > <Karim.Belabas@math.u-bordeaux.fr> wrote: > > > > > > Hi, > > > > > > Not sure what you mean by "mirror reflection transformation". If it's > > > an ordinary reflection s = s_H with respect to some hyperplane H then, > > > > Sorry for the unclear in my previous description. It seems your > > description above is exactly what I mean. > > > > More specifically, my goal is to find the relationship of parity > > transformation (also called parity inversion) [1] between two sets of > > points, as the examples shown in between a pair of enantiomorphic > > space groups [2]. > > > > > let v be a unit vector orthogonal to H, we have s(x) = x - 2 <x,v> v. > > > So s(x) - x should be proportional to a constant vector v, which is not > > > the case when you check the rows of A - B; for instance when you > > > renormalize > > > > > > C = A - B; > > > for (i=1,#C[,1], C[i,] /= C[i,1]) > > > > > > the matrix C should have all its rows (roughly) equal. > > > > > > (Since you write that your points are in 8-dimensional space and your > > > matrices are 7 x 8, I gather that you wrote the point coordinates as > > > rows, which is not the standard PARI convention. Anyway, considering > > > columns doesn't work either on you example.) > > > > In my previous example data, each point in 8-dimensional space is > > represented as a row vector. Now, I generated two new sets of point > > pairs, each consisting of 20 points represented as column vectors in > > an 8-dimensional space, as shown below: > > > > ? A=[6, 23, -5, 25, 22, 16, 25, -4, -22, 4, -20, 13, 10, -7, 9, 2, 19, > > 24, 0, -14; 0, 15, -1, -15, 4, 0, 1, 7, 4, -15, 11, -11, -12, -3, -19, > > -6, 10, 13, -2, 6; 23, 3, -22, 12, 10, 3, 24, 21, -20, 23, 6, 24, 10, > > -9, 4, 20, 5, 18, -24, 16; 17, -6, -15, 18, 10, -10, -2, 2, 8, -7, > > -24, 13, 7, -10, -21, -13, 9, -1, 24, 14; 25, 24, -19, -12, -16, -15, > > 5, 17, 23, -10, 25, 3, -15, 24, 25, 10, 8, 7, -5, -24; 21, -22, 14, 0, > > -10, -21, -5, 8, 9, -8, 7, 2, -2, -21, -15, -13, 16, -4, -21, 15; 22, > > -15, -4, -8, 7, -2, 11, -9, -6, -7, 1, 23, -25, -22, 9, 20, 18, 17, 4, > > 9; 17, -23, 11, 0, -15, -18, -21, 8, -14, 17, 2, 17, -9, 21, -17, 25, > > -13, -9, 17, 14]; > > > > ? B=[-7, 6, 9, 13, -20, 22, 25, 4, 0, -14, 19, 24, 2, 25, -5, 16, 10, > > 23, -4, -22; 103/51, -12, -215/17, -445/51, 469/51, 292/51, 47/51, > > -35/17, -38/51, 274/51, -98/51, 201/17, 126/17, -793/51, 55/17, > > 172/17, -568/51, 553/51, 29/51, -12; -587/51, 29, 14/17, 1166/51, > > 352/51, 466/51, 1226/51, 281/17, -1256/51, 832/51, 559/51, 316/17, > > 226/17, 626/51, -410/17, -35/17, 488/51, 259/51, 1235/51, -12; 2/51, > > -7, -141/17, 895/51, -1408/51, 686/51, -110/51, 321/17, 1352/51, > > 650/51, -757/51, -57/17, 235/17, 862/51, -111/17, 174/17, 445/51, > > -730/51, -554/51, -24; 536/17, 7, 587/17, 109/17, 379/17, -228/17, > > 83/17, 160/17, -53/17, -424/17, -168/17, 89/17, 512/17, -218/17, > > -215/17, 3/17, -233/17, 302/17, 125/17, -1; -559/51, -3, -39/17, > > 334/51, 173/51, -334/51, -263/51, 304/17, -943/51, 701/51, -400/51, > > -108/17, 235/17, -56/51, 382/17, -13/17, -14/51, -1546/51, -248/51, > > -23; -1250/51, 28, 99/17, 1115/51, 97/51, 313/51, 563/51, -229/17, > > 172/51, 475/51, 1222/51, 299/17, 226/17, -394/51, -104/17, -120/17, > > -1297/51, -659/51, -295/51, 2; 815/51, 29, -397/17, 751/51, 194/51, > > -853/51, -1067/51, 69/17, 803/51, 746/51, -55/51, -133/17, 197/17, > > 28/51, 115/17, -478/17, -503/51, -961/51, 736/51, 2]; > > > > Please check out and use the above two sets of point pairs in the > > future discussion. > > > > > If you meant something else, please be more specific. > > > > See my above further clarification. Thank you again for the help. > > > > [1] https://en.wikipedia.org/wiki/Parity_(physics) > > [2] http://www.aflowlib.org/prototype-encyclopedia/enantiomorph_info.html > > > > > Cheers, > > > > > > K.B. > > > > Best, > > Zhao > > > > > * Hongyi Zhao [2023-03-11 08:53]: > > > > Hi here, > > > > > > > > I've the following two sets of point pairs in a given dimensional of > > > > space, aka, 8 here, as follows: > > > > > > > > ? A=[-1.12014, -3.17998, -18.2911, 20.1524, -6.94559, -21.8148, > > > > 0.975253, 7.95121; 12.8475, -6.00645, 19.3356, 19.7475, -6.17003, > > > > -2.66469, 24.6888, 5.86053; -16.7258, -22.5862, 20.591, 9.54292, > > > > 18.5927, 21.9645, 20.892, 0.0563033; -17.2971, 5.16334, -16.3141, > > > > 5.35391, -10.307, -13.6297, 23.5236, 24.192; -11.0926, 6.0634, > > > > 19.4003, 21.6093, -1.37237, -21.7654, 4.35257, -3.1105; 11.2137, > > > > -20.5612, -3.41736, 19.6006, -1.13627, -6.21613, 11.5885, 15.2543; > > > > -13.4837, 8.02265, -11.4049, 23.3052, -19.5653, 3.19629, -10.814, > > > > -17.1669]; > > > > ? B=[-19.6192, -19.8916, 21.9217, 9.26674, 22.0351, 19.6121, 19.8591, > > > > 1.64306; 1.39387, -5.56517, 13.6578, 22.8011, -16.2283, -11.6133, > > > > 8.81048, -9.95819; -0.18953, 6.13486, 25.3313, 18.5031, 9.34097, > > > > -13.2645, 20.0343, 13.0102; -3.4197, -6.93323, 3.31249, 18.2038, > > > > 16.274, -18.1138, 6.36411, 23.2793; -3.91626, -0.57597, -17.0051, > > > > 19.8855, -3.61887, -24.0882, -0.0230154, 9.48462; -24.6641, 18.4349, > > > > -6.2631, 22.238, -6.2633, -5.89393, -14.8056, -11.0355; -12.9205, > > > > 1.0875, -18.3268, 5.77166, -15.5141, -10.0714, 25.0861, 21.7919]; > > > > > > > > I want to determine whether they are connetted by a mirror reflection > > > > transformation, and if so, identify such a transformation matrix > > > > connecting them. > > > > > > > > I wonder if PARI/GP can help to do the trick in this case. Any tips > > > > will be appreciated. > > > > > > > > Regards, > > > > Zhao > > > > -- > > > > Assoc. Prof. Hongsheng Zhao <hongyi.zhao@gmail.com> > > > > Theory and Simulation of Materials > > > > Hebei Vocational University of Technology and Engineering > > > > No. 473, Quannan West Street, Xindu District, Xingtai, Hebei province > > > > > > > > > > K.B. > > > -- > > > Pr Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique > > > Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77 > > > http://www.math.u-bordeaux.fr/~kbelabas/ > > > ` > > > > K.B. > -- > Pr Karim Belabas, U. Bordeaux, Vice-président en charge du Numérique > Institut de Mathématiques de Bordeaux UMR 5251 - (+33) 05 40 00 29 77 > http://www.math.u-bordeaux.fr/~kbelabas/ > `