static List <List <ConsideredOrientation> > GetTestedOrientations() { const double minHalfDistance = 2; const double maxHalfDistance = 6; const int orientationListSplit = 50; const int orientationsChecked = 20; Random random = new Random(0); List <List <ConsideredOrientation> > allSplits = new List <List <ConsideredOrientation> >(); for (int i = 0; i < orientationListSplit; ++i) { List <ConsideredOrientation> orientations = new List <ConsideredOrientation>(); for (int j = 0; j < orientationsChecked; ++j) { ConsideredOrientation orientation = new ConsideredOrientation(); do { double angle = Angle.FromFraction(random.NextDouble() * 0.5); double distance = MathEx.InterpolateExponential(minHalfDistance, maxHalfDistance, random.NextDouble()); orientation.CheckLocation = (distance * Angle.ToVector(angle)).Round(); } while (orientation.CheckLocation == new Point() || orientation.CheckLocation.Y < 0); orientation.OrientationVector = Angle.ToVector(Angle.Add(Angle.ToOrientation(Angle.Atan(orientation.CheckLocation)), Math.PI)); if (!orientations.Any(info => info.CheckLocation == orientation.CheckLocation)) { orientations.Add(orientation); } } orientations.Sort((left, right) => MathEx.CompareYX(left.CheckLocation, right.CheckLocation)); allSplits.Add(orientations); } return(allSplits); }
static ConsideredOrientation[][] PlanOrientations() { var random = new OrientationRandom(); var splits = new ConsideredOrientation[Parameters.OrientationSplit][]; for (int i = 0; i < Parameters.OrientationSplit; ++i) { var orientations = splits[i] = new ConsideredOrientation[Parameters.OrientationsChecked]; for (int j = 0; j < Parameters.OrientationsChecked; ++j) { var sample = orientations[j] = new ConsideredOrientation(); while (true) { double angle = random.Next() * Math.PI; double distance = Doubles.InterpolateExponential(Parameters.MinOrientationRadius, Parameters.MaxOrientationRadius, random.Next()); sample.Offset = (distance * DoubleAngle.ToVector(angle)).Round(); if (sample.Offset == IntPoint.Zero) { continue; } if (sample.Offset.Y < 0) { continue; } bool duplicate = false; for (int jj = 0; jj < j; ++jj) { if (orientations[jj].Offset == sample.Offset) { duplicate = true; } } if (duplicate) { continue; } break; } sample.Orientation = DoubleAngle.ToVector(DoubleAngle.Add(DoubleAngle.ToOrientation(DoubleAngle.Atan((DoublePoint)sample.Offset)), Math.PI)); } } return(splits); }