public SurfaceModel3D(IEnumerable <object> x, IEnumerable <object> y, IEnumerable <object> z) { int[] xLengths = new int[3]; int[] yLengths = new int[3]; IEnumerable <double>[] imageEnumerators = new IEnumerable <double> [3]; IEnumerable <double>[] adjustedImageEnumerators = new IEnumerable <double> [3]; imageEnumerators[0] = GeneralArray.ToImageEnumerator(x, out xLengths[0], out yLengths[0]); imageEnumerators[1] = GeneralArray.ToImageEnumerator(y, out xLengths[1], out yLengths[1]); imageEnumerators[2] = GeneralArray.ToImageEnumerator(z, out xLengths[2], out yLengths[2]); int xLength = -1; int yLength = -1; if (yLengths[0] == 0) { xLength = xLengths[0]; } if (yLengths[1] == 0) { yLength = xLengths[1]; } for (int i = 0; i < 3; ++i) { adjustedImageEnumerators[i] = imageEnumerators[i]; if (yLengths[i] != 0) { if (xLength == -1) { xLength = xLengths[i]; } else if (xLength != xLengths[i]) { throw new ArgumentException("x dimensions are not consistent."); } if (yLength == -1) { yLength = yLengths[i]; } else if (yLength != yLengths[i]) { throw new ArgumentException("y dimensions are not consistent."); } } } if (yLengths[0] == 0) { adjustedImageEnumerators[0] = MathHelper.MeshGridX(imageEnumerators[0], yLength); } if (yLengths[1] == 0) { adjustedImageEnumerators[1] = MathHelper.MeshGridY(imageEnumerators[1], xLength); } if (yLengths[2] == 0 && xLengths[2] != xLength * yLength) { throw new ArgumentException("Wrong number of elements in z."); } CreateMesh(adjustedImageEnumerators[0], adjustedImageEnumerators[1], adjustedImageEnumerators[2], xLength, yLength); }
public SurfaceModel3D(IEnumerable <object> z) { int xLength, yLength; var za = GeneralArray.ToImageEnumerator(z, out xLength, out yLength); if (yLength == 0) { throw new ArgumentException("z cannot be a vector."); } var xa = MathHelper.MeshGridX(MathHelper.Counter(xLength), yLength); var ya = MathHelper.MeshGridY(MathHelper.Counter(yLength), xLength); CreateMesh(xa, ya, za, xLength, yLength); }