コード例 #1
0
ファイル: Form1.cs プロジェクト: REW-Z/SPTools
        private void buttonReadPath_Click(object sender, EventArgs e)
        {
            XDocument document = XDocument.Load(textBoxPath.Text.Trim());

            if (document != null)
            {
                List <XElement> parts     = document.Element("Aircraft").Element("Assembly").Element("Parts").Elements().ToList();
                List <XElement> partsMark = parts.FindAll(x => REW_Func.ReadIntArrayStr(x.Attribute("materials").Value)[0] == 14);

                fuselagesType = partsMark[0].Attribute("partType").Value;
                if (fuselagesType != "Fuselage-Body-1" && fuselagesType != "Fuselage-Hollow-1")
                {
                    return;
                }

                string strPosition = partsMark[0].Attribute("position").Value;
                string strRotation = partsMark[0].Attribute("rotation").Value;
                string strSection2 = partsMark[0].Element("Fuselage.State").Attribute("frontScale").Value;
                string strSection1 = partsMark[0].Element("Fuselage.State").Attribute("rearScale").Value;

                string strOffset = partsMark[0].Element("Fuselage.State").Attribute("offset").Value; //run rise length
                string strRun    = strOffset.Substring(0, strOffset.IndexOf(','));
                string strRise   = strOffset.Substring(strOffset.IndexOf(',') + 1, strOffset.LastIndexOf(',') - strOffset.IndexOf(',') - 1);
                string strLength = strOffset.Substring(strOffset.LastIndexOf(',') + 1);

                textBox_widthL.Text  = strSection1.Substring(0, strSection1.IndexOf(','));
                textBox_heightL.Text = strSection1.Substring(strSection1.IndexOf(',') + 1);
                textBox_widthR.Text  = strSection2.Substring(0, strSection2.IndexOf(','));
                textBox_heightR.Text = strSection2.Substring(strSection2.IndexOf(',') + 1);
                textBox_Run.Text     = strRun;
                textBox_Rise.Text    = strRise;
                textBox_length.Text  = strLength;
                textBoxPosition.Text = strPosition;
                textBoxRotation.Text = strRotation;
            }
        }
コード例 #2
0
        public double[] Value(double x)
        {
            double a = point_1.x;
            double b = point_1.y;
            double p = crossPoint.x;
            double q = crossPoint.y;
            double m = point_2.x;
            double n = point_2.y;


            if (REW_Func.Root((m - 2 * p + a), (2 * p - 2 * a), a - x) == null)
            {
                return(null);
            }
            else if (REW_Func.Root((m - 2 * p + a), (2 * p - 2 * a), a - x).Length == 1)
            {
                double t = REW_Func.Root((m - 2 * p + a), (2 * p - 2 * a), a - x)[0];
                double y = (n - 2 * q + b) * t * t + (2 * q - 2 * b) * t + b;
                return(new double[1] {
                    y
                });
            }
            else
            {
                double t1 = REW_Func.Root((m - 2 * p + a), (2 * p - 2 * a), a - x)[0];
                double t2 = REW_Func.Root((m - 2 * p + a), (2 * p - 2 * a), a - x)[1];

                if (t1 >= 0 && t1 <= 1)
                {
                    if (t2 >= 0 && t2 <= 1)
                    {
                        double y1 = (n - 2 * q + b) * t1 * t1 + (2 * q - 2 * b) * t1 + b;
                        double y2 = (n - 2 * q + b) * t2 * t2 + (2 * q - 2 * b) * t2 + b;
                        if (y1 < y2)
                        {
                            return(new double[2] {
                                y1, y2
                            });
                        }
                        else
                        {
                            return(new double[2] {
                                y2, y1
                            });
                        }
                    }
                    else
                    {
                        double y1 = (n - 2 * q + b) * t1 * t1 + (2 * q - 2 * b) * t1 + b;
                        return(new double[1] {
                            y1
                        });
                    }
                }
                else
                {
                    if (t2 >= 0 && t2 <= 1)
                    {
                        double y2 = (n - 2 * q + b) * t2 * t2 + (2 * q - 2 * b) * t2 + b;
                        return(new double[1] {
                            y2
                        });
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            //float y = (n - 2 * q + b) * t * t + (2 * q - 2 * b) * t + b;
            //return (new float[1]{y});
        }