Ejemplo n.º 1
0
 public object VibrationCalc([FromBody] SensorCond form)
 {
     using (var entity = new SecureCloud_Entities())
     {
         return(calc(form).GetData());
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 矩阵运算,得出震源坐标
        /// </summary>
        /// <param name="items"></param>
        /// <param name="iterationEnd"></param>
        /// <returns></returns>
        private Matrix calc(SensorCond form)
        {
            try
            {
                Matrix    os      = null;
                ShockData minData = form.items[0];
                int       length  = form.items.Count - 1;
                foreach (var item in form.items)
                {
                    if (item.t < minData.t)
                    {
                        minData = item;
                    }
                }
                minData.isCalc = false;
                Matrix minMt = new Matrix(1, 4, minData.getArray());
                do
                {
                    double[,] dou = new double[length, 4];
                    double[] yi    = new double[length];
                    int      count = -1;
                    for (int i = 0; i < form.items.Count; i++)
                    {
                        var item = form.items[i];
                        if (!item.isCalc)
                        {
                            item.isCalc = true;
                            continue;
                        }
                        count++;
                        item.tci  = minMt[0, 3] + (Math.Sqrt(Math.Pow(item.x - minMt[0, 0], 2) + Math.Pow(item.y - minMt[0, 1], 2) + Math.Pow(item.z - minMt[0, 2], 2)) / item.speed);
                        yi[count] = (item.T - item.tci);
                        item.Ri   = Math.Sqrt(Math.Pow(item.x - minMt[0, 0], 2) + Math.Pow(item.y - minMt[0, 1], 2) + Math.Pow(item.z - minMt[0, 2], 2));
                        double[] itemDou = item.calc(minMt);
                        dou[count, 0] = itemDou[0];
                        dou[count, 1] = itemDou[1];
                        dou[count, 2] = itemDou[2];
                        dou[count, 3] = itemDou[3];
                    }

                    Matrix mtY   = new Matrix(1, yi.Length, yi).Transpose();
                    Matrix mtA   = new Matrix(dou);
                    Matrix mtAt  = mtA.Transpose();
                    Matrix mtANi = (mtAt * mtA);
                    mtANi.InvertSsgj();
                    Matrix resultMtx = mtANi * mtAt * mtY;
                    os     = resultMtx.Transpose();
                    length = form.items.Count;
                } while (calcIteration(os, minMt, form.Cond));
                return(globalMtx);
            }
            catch (Exception)
            {
            }
            return(null);
        }