Ejemplo n.º 1
0
        public void StaticAngleBetweenTest(double x1, double y1, double x2, double y2, double expectedAngleInDegrees)
        {
            var vector1 = new Vector2D(x1, y1);
            var vector2 = new Vector2D(x2, y2);

            Assert.AreEqual(Conversion.DegreesToRadians(expectedAngleInDegrees), Vector2D.AngleBetween(vector1, vector2), Helper.E);
        }
Ejemplo n.º 2
0
    static void Main(string[] args)
    {
        Vector3D  r     = new Vector3D(0, 0, 0);
        Vector3D  v3D1  = new Vector3D(1, 2, 3);
        Vector3DN v3DN1 = v3D1.normalized;

        TestIVector3(ref r, v3D1, v3DN1);


        Vector2D v0  = new Vector2D(10, 20);
        Vector2D v1  = new Vector2D(15, 15);
        Vector2D v00 = new Vector2D(0, 0);
        Vector2D v11 = new Vector2D(1, 1);

        Vector2D vSelectLow = (v0 < v1).Select(v11, v00);

        Console.WriteLine("SelectLow=" + vSelectLow);

        Bool2 b2False  = new Bool2(false, false);
        Bool2 b2True   = new Bool2(true, true);
        Bool2 b2Select = (v0 < v1).Select(b2False, b2True);

        Vector2DN v45   = new Vector2D(1, 1).normalized;
        Vector2DN v90   = new Vector2D(0, 1).normalized;
        float     angle = v45.AngleBetween(v90).radian;

        Console.WriteLine("AngleBetween v45 and v90=" + angle + " radian");

        Bool2 b0 = v45 < v90;
        Bool2 b1 = v45 < v11;

        Console.ReadLine();
    }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        Vector3D  r     = new Vector3D(0, 0, 0);
        Vector3D  v3D1  = new Vector3D(1, 2, 3);
        Vector3DN v3DN1 = v3D1.normalized;

        TestIVector3(ref r, v3D1, v3DN1);


        Vector2D v0  = new Vector2D(10, 20);
        Vector2D v1  = new Vector2D(15, 15);
        Vector2D v00 = new Vector2D(0, 0);
        Vector2D v11 = new Vector2D(1, 1);

        Vector2D vSelectLow = (v0 < v1).Select(v11, v00);

        Debug.Log("SelectLow float=" + vSelectLow);

        Bool2 b2False  = new Bool2(false, false);
        Bool2 b2True   = new Bool2(true, true);
        Bool2 b2Select = (v0 < v1).Select(b2False, b2True);

        Debug.Log("SelectLow bool=" + b2Select);

        Vector2DN v45   = new Vector2D(1, 1).normalized;
        Vector2DN v90   = new Vector2D(0, 1).normalized;
        float     angle = v45.AngleBetween(v90).radian;

        Debug.Log("AngleBetween v45 and v90=" + angle + " radian");

        Bool2 b0 = v45 < v90;
        Bool2 b1 = v45 < v11;
    }
Ejemplo n.º 4
0
        public void Vector2Angle()
        {
            Vector2D a = new Vector2D(1, 0);
            Vector2D b = new Vector2D(0, 1);

            Assert.AreEqual(0, a.AngleBetween(b));
        }
Ejemplo n.º 5
0
            public void Draw(Graphics g, DiagramPainter dp, ReferenceStyle style)
            {
                Pen pen = dp.GetPen(style.LineColor, style.LineWidth);

                if (style.LineWay == LineWayType.Rectangular)
                {
                    if (Vector2D.AngleBetween(StartVec, EndVec) < 0.1) // asi to bude rovnobezne
                    {
                        /*
                         * Start          beglev
                         *
                         * m1             m2
                         *
                         * endlev         End
                         */
                        Point2D beglev = new Line2D(Start, StartVec.NormalVector).ComPoint(new Line2D(End, EndVec)) ?? new Point2D();
                        Point2D endlev = new Line2D(End, EndVec.NormalVector).ComPoint(new Line2D(Start, StartVec)) ?? new Point2D();
                        Point2D m1     = Start + (endlev - Start) / 2;
                        Point2D m2     = beglev + (End - beglev) / 2;
                        g.DrawLine(pen, (Point)Start, (Point)m1);
                        g.DrawLine(pen, (Point)m1, (Point)m2);
                        g.DrawLine(pen, (Point)m2, (Point)End);
                        ReferencePainter.DrawArrow(dp, g, (Point)m2, (Point)End, style.Arrow);
                    }
                    else
                    {
                        /*
                         * Start
                         *
                         *
                         * m         End
                         */
                        Point2D m = new Line2D(Start, StartVec).ComPoint(new Line2D(End, EndVec)) ?? new Point2D();
                        g.DrawLine(pen, (Point)Start, (Point)m);
                        g.DrawLine(pen, (Point)m, (Point)End);
                        ReferencePainter.DrawArrow(dp, g, (Point)m, (Point)End, style.Arrow);
                    }
                }
                if (style.LineWay == LineWayType.Direct)
                {
                    g.DrawLine(pen, Start, End);
                    ReferencePainter.DrawArrow(dp, g, (Point)Start, (Point)End, style.Arrow);
                }
            }
Ejemplo n.º 6
0
    static void Main(string[] args)
    {
        Vector2D v0 = new Vector2D(10,20);
        Vector2D v1 = new Vector2D(15,15);
        Vector2D v00 = new Vector2D(0,0);
        Vector2D v11 = new Vector2D(1, 1);

        Vector2D vSelectLow = (v0<v1).Select(v11,v00);
        Console.WriteLine("SelectLow=" + vSelectLow);

        Vector2DN v45 = new Vector2D(1, 1).normalized;
        Vector2DN v90 = new Vector2D(0, 1).normalized;
        float angle = v45.AngleBetween(v90).radian;
        Console.WriteLine("AngleBetween v45 and v90=" + angle + " radian");

        Bool2 b0 = v45 < v90;
        Bool2 b1 = v45 < v11;

        Console.ReadLine();
    }
Ejemplo n.º 7
0
        private void ClockForm_Paint(object sender, PaintEventArgs e)
        {
            Graphics G = e.Graphics;

            G.SmoothingMode = SmoothingMode.HighQuality;

            Vector2D Center = this.ClockCenter;
            float    CX     = Center.A;
            float    CY     = Center.B;

            AllArrows.UpdateVectors();

            Vector2D HourVector = AllArrows.Hour.Vector;
            Vector2D MinVector  = AllArrows.Minute.Vector;
            Vector2D SecVector  = AllArrows.Second.Vector;

            //Angle AngleBetween_H_M = new Angle(HourVector.AngleBetween2(MinVector).Radians * -1.0f, AngleType.Radians);
            //Angle AngleBetween_M_S = new Angle(MinVector.AngleBetween2(SecVector).Radians * -1.0f, AngleType.Radians);

            float PieSize = 150.0f;

            using
            (
                Brush G1 = new SolidBrush(Color.FromArgb(128, Color.Gold)) /* new LinearGradientBrush
                                                                            * (
                                                                            * new PointF
                                                                            * {
                                                                            * X = MinVector.A * PieSize,
                                                                            * Y = MinVector.B * PieSize,
                                                                            * },
                                                                            * new PointF
                                                                            * {
                                                                            * X = HourVector.A * PieSize + 1,
                                                                            * Y = HourVector.B * PieSize + 1,
                                                                            * },
                                                                            * ClockStyle.Arrows.Minute.Style.LineColor,
                                                                            * ClockStyle.Arrows.Hour.Style.LineColor
                                                                            * ) */
            )
            {
                G.FillPie
                (
                    G1,
                    CX - PieSize,
                    CY - PieSize,
                    2 * PieSize,
                    2 * PieSize,
                    DebugPieStartAngle,
                    DebugPieRelativeAngle
                );
            }

            RenderClock(G, CX, CY, AllArrows.ClockStyle);

            G.DrawArc
            (
                Pens.Orange,
                CX - 150.0f,
                CY - 150.0f,
                2 * 150.0f,
                2 * 150.0f,
                DebugPieStartAngle,
                DebugPieRelativeAngle
            );


            Vector2D AVec = AllArrows.User1.Vector;
            Vector2D BVec = AllArrows.User2.Vector;

            if (!RadioBtn_TestVectors.Checked)
            {
                AVec = AllArrows.Minute.Vector;
                BVec = AllArrows.SecGhost.Vector;
            }

            label1.Text =
                $"UsrArr1.fang = {AllArrows.User1.Vector.AbsAngle.Degrees:0.###} " +
                $"({AllArrows.User1.Vector.Angle.Degrees:0.###})\n" +
                $"UsrArr2.fang = {AllArrows.User2.Vector.AbsAngle.Degrees:0.###} " +
                $"({AllArrows.User2.Vector.Angle.Degrees:0.###})\n" +
                $"Angle = {AVec.AngleBetween(BVec).Degrees:0.###}";
        }