// Утворює промені парарельні x або y. Промені паралельні осі Z будуть утворюватися іншим чином private static Ray[,] GetParallelRays(ParallelTo RayParallelism, double SizeOfCubes, double startValue, double endValue, double MinOfFirstDim, double MaxOfFirstDim, double MinOfSecondDim, double MaxOfSecondDim) { int countOfLines = (int)((MaxOfSecondDim - MinOfSecondDim) / SizeOfCubes); int countOfColumns = (int)((MaxOfFirstDim - MinOfFirstDim) / SizeOfCubes); countOfColumns++; countOfLines++; Ray[,] resultingArrayOfRays = new Ray[countOfLines, countOfColumns]; int secondDimCount = 0; int firstDimCount = 0; switch (RayParallelism) { case ParallelTo.X: secondDimCount = 0; for (double y = MinOfSecondDim; y < MaxOfSecondDim; y += SizeOfCubes) { firstDimCount = 0; for (double z = MinOfFirstDim; z < MaxOfFirstDim; z += SizeOfCubes) { Vertex startVertex = new Vertex(startValue, y, z); Vertex endVertex = new Vertex(endValue, y, z); Ray currentRay = Ray.GetRay(startVertex, endVertex, ParallelTo.X); resultingArrayOfRays[secondDimCount, firstDimCount] = currentRay; firstDimCount++; } secondDimCount++; } break; case ParallelTo.Y: secondDimCount = 0; for (double z = MinOfSecondDim; z < MaxOfSecondDim; z += SizeOfCubes) { firstDimCount = 0; for (double x = MinOfFirstDim; x < MaxOfFirstDim; x += SizeOfCubes) { Vertex startVertex = new Vertex(x, startValue, z); Vertex endVertex = new Vertex(x, endValue, z); Ray currentRay = Ray.GetRay(startVertex, endVertex, ParallelTo.Y); resultingArrayOfRays[secondDimCount, firstDimCount] = currentRay; firstDimCount++; } secondDimCount++; } break; default: throw new Exception("Rays must be only parallel to x or y in this method"); } return(resultingArrayOfRays); }
public static Ray GetRay(Vertex start, Vertex end, ParallelTo rayParallel, params Vertex[] vertexesOfEntry) { Ray result = new Ray(); result.Start = start; result.End = end; result.RayParallel = rayParallel; result.VertexesOfEntry = new List <Vertex>(); if (vertexesOfEntry.Length != 0) { result.VertexesOfEntry.AddRange(vertexesOfEntry); } return(result); }