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(); }
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 minAngle 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 minAngle 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 minAngle 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 minAngle 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 minAngle: {0}", TotalRotatedAngleAmount); form.totalRotatedAngleTextBox.Text = TotalRotatedAngleAmount.ToString(); }
protected override void InitialLines() { //P is the max for polygon One //Q is the max for polygon Two indexOne = form.firstPolygon.indexMaxYPoint; indexTwo = form.secondPolygon.indexMaxYPoint; //Initialize them should be two horizontal lines DrawInitialSupportLines(); //get the vectors associated with the initial caliper A (P) calAVector1 = new Vector(CaliperA.CenterPoint, CaliperA.P1); calAVector2 = new Vector(CaliperA.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexOne)]); //Get the angle between them angleA = Utility.GetAngle(calAVector1, calAVector2); Console.WriteLine("Angle between first caliper is: {0}", angleA); //Get the vectors associated with the initial caliper B (Q) calBVector1 = new Vector(CaliperB.CenterPoint, CaliperB.P1); calBVector2 = new Vector(CaliperB.CenterPoint, form.secondPolygon.points[form.secondPolygon.IncrementIndex(indexTwo)]); angleB = Utility.GetAngle(calBVector1, calBVector2); Console.WriteLine("Angle between second caliper is: {0}", angleB); }
protected override void InitialLines() { indexOne = form.firstPolygon.indexMaxYPoint; indexTwo = form.firstPolygon.indexMinYPoint; indexThree = form.firstPolygon.indexMaxXPoint; indexFour = form.firstPolygon.indexMinXPoint; //Initialize them to the top and bottom horizontal lines DrawInitialSupportLines(); //==================================== //get the vectors associated with the initial caliper A calAVector1 = new Vector(CaliperA.CenterPoint, CaliperA.P1); calAVector2 = new Vector(CaliperA.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexOne)]); //Get the minAngle between them angleA = Utility.GetAngle(calAVector1, calAVector2); Console.WriteLine("Angle between first caliper Y is: {0}", angleA); //Get the vectors associated with the initial caliper B calBVector1 = new Vector(CaliperB.CenterPoint, CaliperB.P1); calBVector2 = new Vector(CaliperB.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexTwo)]); angleB = Utility.GetAngle(calBVector1, calBVector2); Console.WriteLine("Angle between second caliper Y is: {0}", angleB); //Get the vectors associated with the initial caliper C calCVector1 = new Vector(CaliperC.CenterPoint, CaliperC.P1); calCVector2 = new Vector(CaliperC.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexThree)]); angleC = Utility.GetAngle(calCVector1, calCVector2); Console.WriteLine("Angle between first caliper X is: {0}", angleC); //Get the vectors associated with the initial caliper D calDVector1 = new Vector(CaliperD.CenterPoint, CaliperD.P1); calDVector2 = new Vector(CaliperD.CenterPoint, form.firstPolygon.points[form.firstPolygon.IncrementIndex(indexFour)]); angleD = Utility.GetAngle(calDVector1, calDVector2); Console.WriteLine("Angle between second caliper X is: {0}", angleD); }