Ejemplo n.º 1
0
            public static void Align(List <Vector> coords1
                                     , ref List <Vector> coords2
                                     , int maxiteration = int.MaxValue
                                     , HPack <List <Trans3[]> > outTrajTrans = null
                                     )
            {
                List <Vector>[] ensemble = new List <Vector>[]
                {
                    coords1.HClone(),
           coords2.HClone()
                };
                Align(ref ensemble, maxiteration: maxiteration, outTrajTrans: outTrajTrans);
                Trans3 trans = MinRMSD.GetTrans(coords1, ensemble[0]);

                Vector[] ensemble0 = trans.GetTransformed(ensemble[0]).ToArray();
                Vector[] ensemble1 = trans.GetTransformed(ensemble[1]).ToArray();
                coords2 = new List <Vector>(ensemble1);
            }
Ejemplo n.º 2
0
            public static Trans3 GetTrans(IList <Vector> C1
                                          , IList <Vector> C2
                                          , IList <double> weight
                                          //, Pack<List<Vector>> C2new = null
                                          )
            {
                if (HDebug.Selftest())
                {
                    double[] tweight = new double[weight.Count];
                    for (int i = 0; i < tweight.Length; i++)
                    {
                        tweight[i] = 0.2;
                    }
                    Trans3 ttrans0 = GetTrans(C1, C2, tweight);
                    Trans3 ttrans1 = MinRMSD.GetTrans(C1, C2);
                    HDebug.AssertTolerance(0.0001, ttrans0.ds - ttrans1.ds);
                    HDebug.AssertTolerance(0.0001, ttrans0.dt - ttrans1.dt);
                    HDebug.AssertTolerance(0.0001, new Vector(ttrans0.dr.ToArray()) - ttrans1.dr.ToArray());
                    HDebug.AssertTolerance(0.0001, (ttrans0.TransformMatrix - ttrans1.TransformMatrix));
                }
                HDebug.Assert(C1.Count == C2.Count);
                HDebug.Assert(C1.Count == weight.Count);
                //Trans3 trans = ICP3.OptimalTransform(C2, C1);
                Trans3 trans = ICP3.OptimalTransformWeighted(C2, C1, weight);

                if (HDebug.IsDebuggerAttached)
                {
                    Vector[] C2updated = trans.GetTransformed(C2).ToArray();
                    double   RMSD0     = 0;
                    double   RMSD1     = 0;
                    for (int i = 0; i < C1.Count; i++)
                    {
                        RMSD0 += (C1[i] - C2[i]).Dist2;
                        RMSD1 += (C1[i] - C2updated[i]).Dist2;
                    }
                    //Debug.AssertTolerance(0.00000001, Math.Abs(RMSD1 - RMSD0));
                }
                return(trans);
            }