Beispiel #1
0
	public static Mesh4D HyperPrism(Vector3[] hyperBase, int heightSegments, float height){

		Vector4[] vertices = new Vector4[hyperBase.Length * heightSegments];
		int i = 0;
		foreach (Vector3 basePoint in hyperBase) {
			for (float w = 0; w < height; w += height / heightSegments) {
				vertices [i] = new Vector4 (basePoint.x, basePoint.y, basePoint.z, w);
				i++;
			}
		}

		Mesh4D mesh = new Mesh4D (){
			vertices = vertices
		};
		mesh.Apply ();

		return mesh;
	}
Beispiel #2
0
	public static Mesh4D FunctionGraphComplexToComplex(Func<Complex, Complex> func, float xMin, float xMax, float yMin, float yMax, int xPoints, int yPoints){
		Vector4[] vertices = new Vector4[xPoints * yPoints];
		int k = 0;
		int xs = 0;
		int ys = 0;
		for (float x = xMin; x < xMax; x += (xMax - xMin) / xPoints) {
			xs += 1;
			if (xs > xPoints)
				break;
			ys = 0;
			for (float y = yMin; y < yMax; y += (yMax - yMin) / yPoints) {
				ys += 1;
				if (ys > yPoints)
					break;
				Complex value = func (new Complex (x, y));
				vertices [k] = new Vector4 (x, y, (float)value.Real, (float)value.Imaginary);
				k++;
			}
		}
		List<int> edges = new List<int> ();
		int end = xPoints * yPoints;
		for (int i = 0; i < end-1; i++) {
			if ((i+1) % yPoints != 0) {
				edges.Add (i);
				edges.Add (i + 1);
			}
			if (i < end - yPoints) {
				edges.Add (i);
				edges.Add (i + yPoints);
			}
		}
		Mesh4D mesh = new Mesh4D () {
			vertices = vertices,
			edges = edges.ToArray()
		};
		mesh.Apply ();
		return mesh;
	}