Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IEnumerable<VectorOption> options = GenerateOptions(hailstones[0], hailstones[1]);
- foreach (Line hailstone in hailstones.Skip(2))
- {
- options = FilterVectorOptions(hailstone, options);
- }
- VectorOption? theOption = options.FirstOrDefault();
- if (theOption == null)
- {
- Console.WriteLine("No solution found");
- }
- else
- {
- Console.WriteLine($"Point found: {theOption.Line}");
- Console.WriteLine(theOption.Line.StartPoint.AddAllDimensions());
- }
- IEnumerable<VectorOption> GenerateOptions(Line line1, Line line2)
- {
- for (int i = -500; i < 500; i++)
- {
- for (int j = -500; j < 500; j++)
- {
- VectorOption? option = FindVectorOptionFor(line1, line2, i, j);
- if (option != null)
- {
- yield return option;
- }
- }
- }
- }
- IEnumerable<VectorOption> FilterVectorOptions(Line hailstone, IEnumerable<VectorOption> vectorOptions)
- {
- foreach (VectorOption option in vectorOptions)
- {
- (long time, Point point)? test = hailstone.Intersect(option.Line);
- if (test.HasValue && test.Value.time >= 0)
- {
- yield return option;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement