/// <summary>
            /// 转换为欧拉角表示形式的外方元素
            /// </summary>
            /// <returns></returns>
            public OutsideElement ToOutElem3()
            {
                OutsideElement oe = new OutsideElement();

                oe.Spos  = Spos.Clone();
                oe.omega = Math.Asin(-2 * (q2 * q3 - q0 * q1));
                if (oe.omega < -Math.PI)
                {
                    oe.omega += 2 * Math.PI;
                }
                oe.phi = Math.Atan2(-2 * (q1 * q3 + q0 * q2) * Math.Cos(oe.omega),
                                    (q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3) * Math.Cos(oe.omega));
                if (oe.phi < -Math.PI)
                {
                    oe.phi += 2 * Math.PI;
                }

                oe.kappa = Math.Atan2(2 * (q1 * q2 + q0 * q3) * Math.Cos(oe.omega),
                                      (q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3) * Math.Cos(oe.omega));
                if (oe.kappa < -Math.PI)
                {
                    oe.kappa += 2 * Math.PI;
                }
                return(oe);
            }
            /// <summary>
            /// 转换为欧拉角表示形式的外方元素
            /// </summary>
            /// <returns></returns>
            public OutsideElement ToOutElem3()
            {
                OutsideElement oe = new OutsideElement {
                    Spos = Spos
                };

                oe.phi   = Math.Atan2(-a3, c3);
                oe.omega = Math.Asin(-b3);
                oe.kappa = Math.Atan2(b1, b2);
                return(oe);
            }
            /// <summary>
            /// 通过初值文件构造
            /// </summary>
            /// <param name="originfile"></param>
            public ParamData(string originfile)
            {
                List <string> data = new List <string>();

                using (StreamReader sr = new StreamReader(originfile, Encoding.Default))
                {
                    while (sr.Peek() != -1)
                    {
                        string s = sr.ReadLine().Trim();
                        if (!string.IsNullOrWhiteSpace(s))
                        {
                            data.Add(s);
                        }
                    }
                }
                if (data.Count == 0)
                {
                    throw new Exception("初值文件数据为空或格式不正确");
                }

                var ss = Regex.Split(data[0], " +|,");

                inE.p0.X = double.Parse(ss[0]);
                inE.p0.Y = double.Parse(ss[1]);
                inE.f    = double.Parse(ss[2]);
                for (int i = 1; i < data.Count; i++)
                {
                    ss = Regex.Split(data[i], " +|,");
                    OutsideElement oe = new OutsideElement();
                    oe.Spos.X = double.Parse(ss[0]);
                    oe.Spos.Y = double.Parse(ss[1]);
                    oe.Spos.Z = double.Parse(ss[2]);
                    oe.phi    = double.Parse(ss[3]);
                    oe.omega  = double.Parse(ss[4]);
                    oe.kappa  = double.Parse(ss[5]);
                    outE.Add(oe);
                }
            }
Example #4
0
            /// <summary>
            /// 通过初值文件构造
            /// </summary>
            /// <param name="originfile"></param>
            public ParamData(string originfile)
            {
                List<string> data = new List<string>();
                using (StreamReader sr = new StreamReader(originfile, Encoding.Default))
                {
                    while(sr.Peek()!=-1)
                    {
                        string s = sr.ReadLine().Trim();
                        if (!string.IsNullOrWhiteSpace(s))
                            data.Add(s);
                    }
                }
                if (data.Count == 0)
                    throw new Exception("初值文件数据为空或格式不正确");

                var ss=Regex.Split(data[0], " +|,");
                inE.p0.X = double.Parse(ss[0]);
                inE.p0.Y = double.Parse(ss[1]);
                inE.f = double.Parse(ss[2]);
                for (int i = 1; i < data.Count; i++)
                {
                    ss = Regex.Split(data[i], " +|,");
                    OutsideElement oe = new OutsideElement();
                    oe.Spos.X = double.Parse(ss[0]);
                    oe.Spos.Y = double.Parse(ss[1]);
                    oe.Spos.Z = double.Parse(ss[2]);
                    oe.phi = double.Parse(ss[3]);
                    oe.omega = double.Parse(ss[4]);
                    oe.kappa= double.Parse(ss[5]);
                    outE.Add(oe);
                }
            }
Example #5
0
 /// <summary>
 /// 转换为欧拉角表示形式的外方元素
 /// </summary>
 /// <returns></returns>
 public OutsideElement ToOutElem3()
 {
     OutsideElement oe = new OutsideElement { Spos = Spos };
     oe.phi = Math.Atan2(-a3 , c3);
     oe.omega = Math.Asin(-b3);
     oe.kappa = Math.Atan2(b1 , b2);
     return oe;
 }
Example #6
0
            /// <summary>
            /// 转换为欧拉角表示形式的外方元素
            /// </summary>
            /// <returns></returns>
            public OutsideElement ToOutElem3()
            {
                OutsideElement oe = new OutsideElement();
                oe.Spos = Spos.Clone();
                oe.omega = Math.Asin(-2 * (q2 * q3 - q0 * q1));
                if (oe.omega< -Math.PI)
                {
                    oe.omega += 2 * Math.PI;
                }
                oe.phi = Math.Atan2(-2 * (q1 * q3 + q0 * q2) * Math.Cos(oe.omega),
                                   (q0 * q0 - q1 * q1 - q2 * q2 + q3 * q3) * Math.Cos(oe.omega));
                if (oe.phi< -Math.PI)
                {
                    oe.phi += 2 * Math.PI;
                }

                oe.kappa = Math.Atan2(2 * (q1 * q2 + q0 * q3) * Math.Cos(oe.omega),
                   (q0 * q0 - q1 * q1 + q2 * q2 - q3 * q3) * Math.Cos(oe.omega));
                if (oe.kappa < -Math.PI)
                {
                    oe.kappa += 2 * Math.PI;
                }
                return oe;
            }