public static float Get(Axis1 axis, Device device)
        {
            CheckInstance();
            var data = _instance._GetAxis(_instance.axis1Handles[(int)axis], device);

            return(data.x);
        }
Exemple #2
0
        private void CommandInit_Click(object sender, EventArgs e) //Кнопка "Данные"
        {
            if (TextDeltaFi.Text == "" || TextLambdaA.Text == "")
            {
                MessageBox.Show("Заполните все поля!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                CommandStart.Enabled = true;
                //DeltaFi = Convert.ToDouble(TextDeltaFi.Text);

                DeltaFi = double.Parse(TextDeltaFi.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo);
                LambdaA = double.Parse(TextLambdaA.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo);

                InitAxis();//Определяет вид систем координат д/отображения катящегося колеса(Аксис1) и траекторий точек радиуса колеса(Аксис2)

                //точка A
                Xa = (float)(-4 * Pi);
                Ya = (float)(1 - LambdaA);

                //Колесо
                Xo = (float)(-4 * Pi);
                Yo = 1;
                Axis1.StatToDin();//
                Axis1.Pix_type = 3;
                Axis1.Pix_Size = 2 / XBase;
                Axis1.PixDraw(Xo, Yo, Color.Red, 2);//

                //радиус
                Axis1.Pix_color = Color.Blue;
                Axis1.Line(Xa, Ya, Xo, Yo, 2); //
                Axis1.DinToPic();              //
            }
        }
Exemple #3
0
 internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary <int, XmlElement> processed)
 {
     base.SetXML(xml, host, processed);
     if (mAxis3 > 0)
     {
         xml.AppendChild(Axis1.GetXML(xml.OwnerDocument, "Axis3", this, processed));
     }
 }
Exemple #4
0
        private void CommandInit_Click(object sender, EventArgs e)
        {
            CommandStart.Enabled = true;

            //радиусы колес
            R1 = float.Parse(TextR1.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo); //неподвижное
            R  = float.Parse(TexTR.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo);  //колесо подвижное

            if (R > R1)
            {
                MessageBox.Show("Радиус внутреннего колеса должен быть меньше радиуса наружного!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                Fimax   = float.Parse(TextFiMax.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo);
                DeltaFi = float.Parse(TextDeltaFi.Text, System.Globalization.NumberStyles.AllowDecimalPoint, System.Globalization.NumberFormatInfo.InvariantInfo);
                //размеры полей отображения
                XBase = (float)Round(R1 + 1.2);
                YBase = (float)Round(R1 + 1.2);
                InitAxis();

                //Колесо неподвижное
                Xo1            = 0;
                Yo1            = 0;
                Axis1.Pix_type = 3;
                Axis1.Pix_Size = 2 * R1 / XBase;
                Axis1.PixDraw(Xo1, Yo1, Color.Black, 1);

                //Колесо подвижное
                Xo             = R1 - R;
                Yo             = 0;
                Axis1.Pix_Size = 2 * R / XBase;
                Axis1.PixDraw(Xo, Yo, Color.Blue, 2);

                //Начальные координаты точки А
                Xa = R1;
                Ya = 0;
                //радиус
                Axis1.Pix_color = Color.Black;
                Axis1.Line(Xa, Ya, Xo, Yo, 2);
                Axis1.DinToPic();

                m  = R / R1;
                Fi = 0;

                //Отображение траектории точки А
                while (Fi < Fimax)
                {
                    X = (float)((R1 - R) * Cos(m * Fi) + R * Cos(Fi - m * Fi));
                    Y = (float)((R1 - R) * Sin(m * Fi) - R * Sin(Fi - m * Fi));
                    Axis2.PixDraw(X, Y, Color.Black, 0);
                    Fi = Fi + DeltaFi;
                }
                ;

                Fi = 0;
            }
        }
Exemple #5
0
        // Evaluate the quadratic function Q(X) = (X-K)^T * M * (X-K) - 1.
        public double Evaluate(Vector2d point)
        {
            Vector2d diff   = point - Center;
            double   ratio0 = Axis0.Dot(diff) / Extent[0];
            double   ratio1 = Axis1.Dot(diff) / Extent[1];
            double   value  = ratio0 * ratio0 + ratio1 * ratio1 - (double)1;

            return(value);
        }
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(Axis1 != null ? Axis1.ToStepValue() : "$");
            parameters.Add(Axis2 != null ? Axis2.ToStepValue() : "$");
            parameters.Add(LocalOrigin != null ? LocalOrigin.ToStepValue() : "$");
            parameters.Add(Scale != null ? Scale.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Exemple #7
0
 public void MoveEllipse(double deltaX, double deltaY)
 {
     Center.Move(deltaX, deltaY);
     Vertex1.Move(deltaX, deltaY);
     Vertex2.Move(deltaX, deltaY);
     Vertex3.Move(deltaX, deltaY);
     Vertex4.Move(deltaX, deltaY);
     Foci1.Move(deltaX, deltaY);
     Foci2.Move(deltaX, deltaY);
     Axis1.Move(deltaX, deltaY);
     Axis2.Move(deltaX, deltaY);
     BindingRectangle.Move(deltaX, deltaY);
 }
Exemple #8
0
 public void Draw()
 {
     foreach (var data in this.Data)
     {
         data.Draw(this.Sprites, this.Axis1, this.Axis2, this.Offset);
     }
     Axis1.Draw(this.Sprites, Vector2.UnitX, this.Offset);
     Axis2.Draw(this.Sprites, Vector2.UnitY, this.Offset);
     if (this.Grid != null)
     {
         this.Grid.Draw(this.Sprites, this.Axis1, this.Axis2, this.Offset);
     }
 }
Exemple #9
0
        public void InitAxis()
        {
            Axis1.Axis_Type = 1;
            Axis1.x_Base    = XBase;
            Axis1.y_Base    = YBase;
            Axis1.AxisDraw();

            Axis2.Axis_Type = 1;
            Axis2.Pix_type  = 1;
            Axis2.x_Base    = XBase;
            Axis2.y_Base    = YBase;
            Axis2.Pix_Size  = 0;
            Axis2.AxisDraw();
        }
Exemple #10
0
        //Определяет вид систем координат д/отображения
        private void InitAxis()    //катящегося колеса(Аксис1) и траекторий точек радиуса колеса(Аксис2)
        {
            //Колесо
            Axis1.Axis_Type = 1;
            Axis1.Pix_type  = 3;
            Axis1.Pix_Size  = 2 / XBase;
            Axis1.x_Base    = XBase;
            Axis1.y_Base    = YBase;
            Axis1.AxisDraw(); //рисуем координатную ось 1

            //Траектории
            Axis2.Axis_Type = 1;
            Axis2.x_Base    = XBase;
            Axis2.y_Base    = YBase;
            Axis2.Pix_Size  = 0;
            Axis2.AxisDraw(); //рисуем координатную ось 2
        }
 protected override void setJSON(JObject obj, BaseClassIfc host, HashSet <int> processed)
 {
     base.setJSON(obj, host, processed);
     if (mAxis1 > 0)
     {
         obj["Axis1"] = Axis1.getJson(this, processed);
     }
     if (mAxis2 > 0)
     {
         obj["Axis2"] = Axis2.getJson(this, processed);
     }
     obj["LocalOrigin"] = LocalOrigin.getJson(this, processed);
     if (!double.IsNaN(mScale))
     {
         obj["Scale"] = Scale;
     }
 }
Exemple #12
0
 internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary <int, XmlElement> processed)
 {
     base.SetXML(xml, host, processed);
     if (mAxis1 > 0)
     {
         xml.AppendChild(Axis1.GetXML(xml.OwnerDocument, "Axis1", this, processed));
     }
     if (mAxis2 > 0)
     {
         xml.AppendChild(Axis2.GetXML(xml.OwnerDocument, "Axis2", this, processed));
     }
     xml.AppendChild(LocalOrigin.GetXML(xml.OwnerDocument, "LocalOrigin", this, processed));
     if (!double.IsNaN(mScale))
     {
         xml.SetAttribute("Scale", mScale.ToString());
     }
 }
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     base.setJSON(obj, host, options);
     if (mAxis1 > 0)
     {
         obj["Axis1"] = Axis1.getJson(this, options);
     }
     if (mAxis2 > 0)
     {
         obj["Axis2"] = Axis2.getJson(this, options);
     }
     obj["LocalOrigin"] = LocalOrigin.getJson(this, options);
     if (!double.IsNaN(mScale))
     {
         obj["Scale"] = Scale;
     }
 }
Exemple #14
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            //траектория точки A
            Xa             = (float)((R + R1) * Cos(m * Fi) - R * Cos(Fi + m * Fi));
            Ya             = (float)((R + R1) * Sin(m * Fi) - R * Sin(Fi + m * Fi));
            Axis1.Pix_type = 1;
            Axis1.Pix_Size = 0;
            Axis1.PixDraw(Xa, Ya, Color.Blue, 1);

            //колесо подвижное
            //новые координаты центра колеса
            Xo             = (float)((R + R1) * Cos(m * Fi));
            Yo             = (float)((R + R1) * Sin(m * Fi));
            Axis1.Pix_type = 3;
            Axis1.Pix_Size = 2 * R / XBase;
            Axis1.PixDraw(Xo, Yo, Color.Blue, 2); //рисуем колесо
            Axis1.Line(Xa, Ya, Xo, Yo, 2);        //рисуем радиус
            Axis1.DinToPic();
            Fi  = Fi + DeltaFi;
            Fi1 = Fi * m;
        }
    int GetAxisRaw(Axis1 axis)
    {
        if (axis == Axis1.Horizontal)
        {
            bool left  = Input.GetKeyDown(KeyCode.LeftArrow);
            bool right = Input.GetKeyDown(KeyCode.RightArrow);

            if (left)
            {
                return(-1);
            }

            if (right)
            {
                return(1);
            }

            return(0);
        }
        else if (axis == Axis1.Vertical)
        {
            bool up   = Input.GetKeyDown(KeyCode.UpArrow);
            bool down = Input.GetKeyDown(KeyCode.DownArrow);

            if (up)
            {
                return(1);
            }

            if (down)
            {
                return(-1);
            }

            return(0);
        }


        return(0);
    }
Exemple #16
0
        private void Timer1_Tick(object sender, EventArgs e)
        {
            Lambda = 0;


            while (Lambda < LambdaA)
            {
                X = (float)(Fi - Lambda * Sin(Fi));
                Y = (float)(1 - Lambda * Cos(Fi));
                Axis2.PixDraw(X, Y, Color.Black, 0);
                Lambda = Lambda + DeltaLambda;
            }
            ;

            Xo = (float)Fi;
            Yo = 1;

            //новые координаты точки А
            Xa = (float)(Fi - LambdaA * Sin(Fi));
            Ya = (float)(1 - LambdaA * Cos(Fi));

            //рисуем точку траектории в статический буфер
            Axis1.Pix_type = 1;
            Axis1.Pix_Size = (float)(0.01 * (YBase / XBase));
            Axis1.PixDraw(Xa, Ya, Color.Red, 1);

            //рисуем колесо в динамический буфер
            Axis1.Pix_type = 3;
            Axis1.Pix_Size = 2 / XBase;
            Axis1.PixDraw(Xo, Yo, Color.Red, 2);

            //рисуем радиус в динамический буфер
            Axis1.Pix_color = Color.Blue;
            Axis1.Line(Xa, Ya, Xo, Yo, 2);

            //отображаем общую картинку
            Axis1.DinToPic();
            Fi = Fi + DeltaFi;
        }
Exemple #17
0
        /// <summary>
        /// Writes the coordinate system information in the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <exception cref="System.ArgumentNullException">writer</exception>
        internal void Serialize(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            writer.WriteStartElement("Origin");
            Origin.Serialize(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("Axis1");
            Axis1.Serialize(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("Axis2");
            Axis2.Serialize(writer);
            writer.WriteEndElement();

            writer.WriteStartElement("Axis3");
            Axis3.Serialize(writer);
            writer.WriteEndElement();
        }
Exemple #18
0
 public static string GetActionSet(this Axis1 a) => _GetActionSet(a);
Exemple #19
0
        //Create an ellipse given a binding rectangle.
        public Ellipse(string _name, string _color, Rectangle _BindingRectangle) : base(_name, _color)
        {
            BindingRectangle = _BindingRectangle;
            Line  Diagonal               = new Line(_name + "'s Diagonal", _color, BindingRectangle.myPoints[0], BindingRectangle.myPoints[2]);
            Point CenterOfDiagonal       = new Point("null", "null", ((Diagonal.myPoints[0].X + Diagonal.myPoints[1].X) / 2), ((Diagonal.myPoints[0].Y + Diagonal.myPoints[1].Y) / 2));
            Point CenterOfRectangleEdge1 = new Point("null", "null", ((BindingRectangle.myPoints[0].X + BindingRectangle.myPoints[1].X) / 2), ((BindingRectangle.myPoints[0].Y + BindingRectangle.myPoints[1].Y) / 2));
            Point CenterOfRectangleEdge2 = new Point("null", "null", ((BindingRectangle.myPoints[1].X + BindingRectangle.myPoints[2].X) / 2), ((BindingRectangle.myPoints[1].Y + BindingRectangle.myPoints[2].Y) / 2));
            Point CenterOfRectangleEdge3 = new Point("null", "null", ((BindingRectangle.myPoints[2].X + BindingRectangle.myPoints[3].X) / 2), ((BindingRectangle.myPoints[2].Y + BindingRectangle.myPoints[3].Y) / 2));
            Point CenterOfRectangleEdge4 = new Point("null", "null", ((BindingRectangle.myPoints[3].X + BindingRectangle.myPoints[0].X) / 2), ((BindingRectangle.myPoints[3].Y + BindingRectangle.myPoints[0].Y) / 2));

            Line _Axis1 = new Line(_name + "'s _Axis1", _color, CenterOfRectangleEdge1, CenterOfRectangleEdge3);
            Line _Axis2 = new Line(_name + "'s _Axis2", _color, CenterOfRectangleEdge2, CenterOfRectangleEdge4);

            Center  = CenterOfDiagonal;
            Vertex1 = CenterOfRectangleEdge1;
            Vertex2 = CenterOfRectangleEdge2;
            Vertex3 = CenterOfRectangleEdge3;
            Vertex4 = CenterOfRectangleEdge4;
            Axis1   = _Axis1;
            Axis2   = _Axis2;

            if (Axis1.ComputeLength() > Axis2.ComputeLength())
            {
                //Axis1 is major axis
                if (CenterOfRectangleEdge1.X == CenterOfRectangleEdge3.X)
                {
                    //foci are on the y axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)) - ((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)));
                    Point  _foci1 = new Point(_name + "'s Foci1", _color, CenterOfRectangleEdge1.X, Center.Y - FociDistanceFromCenter);
                    Point  _foci2 = new Point(_name + "'s Foci2", _color, CenterOfRectangleEdge1.X, Center.Y + FociDistanceFromCenter);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
                else
                {
                    //Foci are on the x axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)) - ((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)));
                    Point  _foci1 = new Point(_name + "'s Foci1", _color, Center.X - FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Point  _foci2 = new Point(_name + "'s Foci2", _color, Center.X + FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
            }
            else
            {
                //Axis2 is major axis
                if (CenterOfRectangleEdge1.X == CenterOfRectangleEdge3.X)
                {
                    //foci are on the x axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)) - ((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)));
                    Point  _foci1 = new Point(_name + "'s Foci1", _color, CenterOfRectangleEdge1.X, Center.Y - FociDistanceFromCenter);
                    Point  _foci2 = new Point(_name + "'s Foci2", _color, CenterOfRectangleEdge1.X, Center.Y + FociDistanceFromCenter);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
                else
                {
                    //Focis are on the y axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)) - ((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)));
                    Point  _foci1 = new Point(_name + "'s Foci1", _color, Center.X - FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Point  _foci2 = new Point(_name + "'s Foci2", _color, Center.X + FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
            }
        }
Exemple #20
0
 public override double ComputeArea()
 {
     return(Math.PI * Axis1.ComputeLength() / 2 * Axis2.ComputeLength() / 2);
 }
Exemple #21
0
        //Create an ellipse given a binding rectangle.
        public Ellipse(Rectangle _BindingRectangle)
        {
            BindingRectangle = _BindingRectangle;
            Line  Diagonal               = new Line(BindingRectangle.Vertex1, BindingRectangle.Vertex3);
            Point CenterOfDiagonal       = new Point(((Diagonal.Point1.X + Diagonal.Point2.X) / 2), ((Diagonal.Point1.Y + Diagonal.Point2.Y) / 2));
            Point CenterOfRectangleEdge1 = new Point(((BindingRectangle.Vertex1.X + BindingRectangle.Vertex2.X) / 2), ((BindingRectangle.Vertex1.Y + BindingRectangle.Vertex2.Y) / 2));
            Point CenterOfRectangleEdge2 = new Point(((BindingRectangle.Vertex2.X + BindingRectangle.Vertex3.X) / 2), ((BindingRectangle.Vertex2.Y + BindingRectangle.Vertex3.Y) / 2));
            Point CenterOfRectangleEdge3 = new Point(((BindingRectangle.Vertex3.X + BindingRectangle.Vertex4.X) / 2), ((BindingRectangle.Vertex3.Y + BindingRectangle.Vertex4.Y) / 2));
            Point CenterOfRectangleEdge4 = new Point(((BindingRectangle.Vertex4.X + BindingRectangle.Vertex1.X) / 2), ((BindingRectangle.Vertex4.Y + BindingRectangle.Vertex1.Y) / 2));

            Line _Axis1 = new Line(CenterOfRectangleEdge1, CenterOfRectangleEdge3);
            Line _Axis2 = new Line(CenterOfRectangleEdge2, CenterOfRectangleEdge4);

            Center  = CenterOfDiagonal;
            Vertex1 = CenterOfRectangleEdge1;
            Vertex2 = CenterOfRectangleEdge2;
            Vertex3 = CenterOfRectangleEdge3;
            Vertex4 = CenterOfRectangleEdge4;
            Axis1   = _Axis1;
            Axis2   = _Axis2;

            if (Axis1.ComputeLength() > Axis2.ComputeLength())
            {
                //Axis1 is major axis
                if (CenterOfRectangleEdge1.X == CenterOfRectangleEdge3.X)
                {
                    //foci are on the y axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)) - ((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)));
                    Point  _foci1 = new Point(CenterOfRectangleEdge1.X, Center.Y - FociDistanceFromCenter);
                    Point  _foci2 = new Point(CenterOfRectangleEdge1.X, Center.Y + FociDistanceFromCenter);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
                else
                {
                    //Foci are on the x axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)) - ((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)));
                    Point  _foci1 = new Point(Center.X - FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Point  _foci2 = new Point(Center.X + FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
            }
            else
            {
                //Axis2 is major axis
                if (CenterOfRectangleEdge1.X == CenterOfRectangleEdge3.X)
                {
                    //foci are on the x axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)) - ((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)));
                    Point  _foci1 = new Point(CenterOfRectangleEdge1.X, Center.Y - FociDistanceFromCenter);
                    Point  _foci2 = new Point(CenterOfRectangleEdge1.X, Center.Y + FociDistanceFromCenter);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
                else
                {
                    //Focis are on the y axis
                    double FociDistanceFromCenter = Math.Sqrt(((Axis2.ComputeLength() / 2) * (Axis2.ComputeLength() / 2)) - ((Axis1.ComputeLength() / 2) * (Axis1.ComputeLength() / 2)));
                    Point  _foci1 = new Point(Center.X - FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Point  _foci2 = new Point(Center.X + FociDistanceFromCenter, CenterOfRectangleEdge1.Y);
                    Foci1 = _foci1;
                    Foci2 = _foci2;
                }
            }
        }