public static bool computeSplitPlane(List <float3> vertices, List <int> indices, ref float4 plane) { float[] bmin = { Single.MaxValue, Single.MaxValue, Single.MaxValue }; float[] bmax = { Single.MinValue, Single.MinValue, Single.MinValue }; for (int i = 0; i < vertices.Count; i++) { float3 p = vertices[i]; if (p[0] < bmin[0]) { bmin[0] = p[0]; } if (p[1] < bmin[1]) { bmin[1] = p[1]; } if (p[2] < bmin[2]) { bmin[2] = p[2]; } if (p[0] > bmax[0]) { bmax[0] = p[0]; } if (p[1] > bmax[1]) { bmax[1] = p[1]; } if (p[2] > bmax[2]) { bmax[2] = p[2]; } } float dx = bmax[0] - bmin[0]; float dy = bmax[1] - bmin[1]; float dz = bmax[2] - bmin[2]; float laxis = dx; int axis = 0; if (dy > dx) { axis = 1; laxis = dy; } if (dz > dx && dz > dy) { axis = 2; laxis = dz; } float[] p1 = new float[3]; float[] p2 = new float[3]; float[] p3 = new float[3]; p3[0] = p2[0] = p1[0] = bmin[0] + dx * 0.5f; p3[1] = p2[1] = p1[1] = bmin[1] + dy * 0.5f; p3[2] = p2[2] = p1[2] = bmin[2] + dz * 0.5f; Rect3d b = new Rect3d(bmin, bmax); Rect3d b1 = new Rect3d(); Rect3d b2 = new Rect3d(); splitRect(axis, b, b1, b2, p1); switch (axis) { case 0: p2[1] = bmin[1]; p2[2] = bmin[2]; if (dz > dy) { p3[1] = bmax[1]; p3[2] = bmin[2]; } else { p3[1] = bmin[1]; p3[2] = bmax[2]; } break; case 1: p2[0] = bmin[0]; p2[2] = bmin[2]; if (dx > dz) { p3[0] = bmax[0]; p3[2] = bmin[2]; } else { p3[0] = bmin[0]; p3[2] = bmax[2]; } break; case 2: p2[0] = bmin[0]; p2[1] = bmin[1]; if (dx > dy) { p3[0] = bmax[0]; p3[1] = bmin[1]; } else { p3[0] = bmin[0]; p3[1] = bmax[1]; } break; } computePlane(p1, p2, p3, plane); return(true); }
public void setxyz(float3 xyz) { x = xyz.x; y = xyz.y; z = xyz.z; }
public static float4 Homogenize(float3 v3) { return(Homogenize(v3, 1.0f)); }
//C++ TO C# CONVERTER NOTE: C# does not allow default values for parameters. Overloaded methods are inserted above. //ORIGINAL LINE: float4 Homogenize(const float3 &v3, const float &w =1.0f) public static float4 Homogenize(float3 v3, float w) { return(new float4(v3.x, v3.y, v3.z, w)); }