protected override void RotateCalipers()
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            //A < B
            if (angleA < angleB)
            {
                Console.WriteLine("A < B");
                //NewCalipers for A < B
                minAngle = angleA;
                NewCalipers(1);
                //new angle B
                angleB = angleB - angleA;
                TotalRotatedAngleAmount += angleA;

                calAVector1 = new Vector(CaliperA.CenterPoint, CaliperA.P1);
                calAVector2 = new Vector(CaliperA.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexOne)]);
                Console.WriteLine("CalAvector1: {0}", calAVector1);
                Console.WriteLine("CalAvector2: {0}", calAVector2);
                angleA = Utility.GetAngle(calAVector1, calAVector2);
            }
            //B < A
            else
            {
                Console.WriteLine("B < A");
                //New calipers for B < A
                minAngle = angleB;
                NewCalipers(2);
                //new angle A
                angleA = angleA - angleB;
                TotalRotatedAngleAmount += angleB;

                calBVector1 = new Vector(CaliperB.CenterPoint, CaliperB.P1);
                calBVector2 = new Vector(CaliperB.CenterPoint, form.secondPolygon.points[form.secondPolygon.IncrementIndex(indexTwo)]);
                Console.WriteLine("CalBvector1: {0}", calBVector1);
                Console.WriteLine("CalBvector2: {0}", calBVector2);
                angleB = Utility.GetAngle(calBVector1, calBVector2);
            }

            Console.WriteLine("CaliperA: {0}", CaliperA);
            Console.WriteLine("CaliperB: {0}", CaliperB);
            Console.WriteLine("Angle between first caliper is: {0}", angleA);
            Console.WriteLine("Angle between second caliper is: {0}", angleB);
            Console.WriteLine("Total rotated angle: {0}", TotalRotatedAngleAmount);
            form.totalRotatedAngleTextBox.Text = TotalRotatedAngleAmount.ToString();
        }
Exemplo n.º 2
0
        protected override void RotateCalipers()
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine();

            if (angleA < angleB && angleA < angleC && angleA < angleD)
            {
                Console.WriteLine("A is min");
                minAngle = angleA;
                NewCalipers(1);
                //new angle B, C and D
                angleB = angleB - angleA;
                angleC = angleC - angleA;
                angleD = angleD - angleA;

                TotalRotatedAngleAmount += angleA;

                calAVector1 = new Vector(CaliperA.CenterPoint, CaliperA.P1);
                calAVector2 = new Vector(CaliperA.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexOne)]);
                Console.WriteLine("CalAvector1: {0}", calAVector1);
                Console.WriteLine("CalAvector2: {0}", calAVector2);
                angleA = Utility.GetAngle(calAVector1, calAVector2);
            }
            else if (angleB < angleA && angleB < angleC && angleB < angleD)
            {
                Console.WriteLine("B is min");
                minAngle = angleB;
                NewCalipers(2);
                //new angle A, C and D
                angleA = angleA - angleB;
                angleC = angleC - angleB;
                angleD = angleD - angleB;

                TotalRotatedAngleAmount += angleB;

                calBVector1 = new Vector(CaliperB.CenterPoint, CaliperB.P1);
                calBVector2 = new Vector(CaliperB.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexTwo)]);
                Console.WriteLine("CalBvector1: {0}", calBVector1);
                Console.WriteLine("CalBvector2: {0}", calBVector2);
                angleB = Utility.GetAngle(calBVector1, calBVector2);
            }
            else if (angleC < angleA && angleC < angleB && angleC < angleD)
            {
                Console.WriteLine("C is min");
                minAngle = angleC;
                NewCalipers(3);
                //new angle A, B and D
                angleA = angleA - angleC;
                angleB = angleB - angleC;
                angleD = angleD - angleC;

                TotalRotatedAngleAmount += angleC;

                calCVector1 = new Vector(CaliperC.CenterPoint, CaliperC.P1);
                calCVector2 = new Vector(CaliperC.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexThree)]);
                Console.WriteLine("CalCvector1: {0}", calCVector1);
                Console.WriteLine("CalCvector2: {0}", calCVector2);
                angleC = Utility.GetAngle(calCVector1, calCVector2);
            }
            else
            {
                Console.WriteLine("D is min");
                minAngle = angleD;
                NewCalipers(4);
                //new angle A, B, C
                angleA = angleA - angleD;
                angleB = angleB - angleD;
                angleC = angleC - angleD;

                TotalRotatedAngleAmount += angleD;

                calDVector1 = new Vector(CaliperD.CenterPoint, CaliperD.P1);
                calDVector2 = new Vector(CaliperD.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexFour)]);
                Console.WriteLine("CalDvector1: {0}", calDVector1);
                Console.WriteLine("CalDvector2: {0}", calDVector2);
                angleD = Utility.GetAngle(calDVector1, calDVector2);
            }

            Console.WriteLine("CaliperA: {0}", CaliperA);
            Console.WriteLine("CaliperB: {0}", CaliperB);
            Console.WriteLine("CaliperC: {0}", CaliperC);
            Console.WriteLine("CaliperD: {0}", CaliperD);
            Console.WriteLine("Angle between first caliper is: {0}", angleA);
            Console.WriteLine("Angle between second caliper is: {0}", angleB);
            Console.WriteLine("Angle between third caliper is: {0}", angleC);
            Console.WriteLine("Angle between fourth caliper is: {0}", angleD);
            Console.WriteLine("Total rotated angle: {0}", TotalRotatedAngleAmount);
            form.totalRotatedAngleTextBox.Text = TotalRotatedAngleAmount.ToString();
        }