private LowPolyMotion.xyz NewEndXYZ(LowPolyMotion.GridConfig gridConfig, int rect_i, int rect_j) { LowPolyMotion.xyz result = new LowPolyMotion.xyz(0, 0, rand.Next(LowPolyMotion.rangeZ.min, LowPolyMotion.rangeZ.max)); int edgeIndex = rand.Next(0, 4);// 0~3: 上下左右边 double bias = rand.NextDouble(); switch (edgeIndex) { case 0: result.x = (int)(gridConfig.getCrossCellWidth() * rect_i + gridConfig.getCrossCellWidth() * bias); result.y = gridConfig.getDirectionCellHeight() * rect_j; break; case 1: result.x = (int)(gridConfig.getCrossCellWidth() * rect_i + gridConfig.getCrossCellWidth() * bias); result.y = gridConfig.getDirectionCellHeight() * (rect_j + 1); break; case 2: result.x = gridConfig.getCrossCellWidth() * rect_i; result.y = (int)(gridConfig.getDirectionCellHeight() * rect_j + gridConfig.getDirectionCellHeight() * bias); break; default: result.x = gridConfig.getCrossCellWidth() * (rect_i + 1); result.y = (int)(gridConfig.getDirectionCellHeight() * rect_j + gridConfig.getDirectionCellHeight() * bias); break; } return(result); }
public static LowPolyMotion.xyz Cal_3DGetFocus(LowPolyMotion.xyz p1, LowPolyMotion.xyz p2, LowPolyMotion.xyz p3) // 求空间三角形重心坐标 { LowPolyMotion.xyz oP = new LowPolyMotion.xyz(0, 0, 0); oP.x = (p1.x + p2.x + p3.x) / 3; oP.y = (p1.y + p2.y + p3.y) / 3; oP.z = (p1.z + p2.z + p3.z) / 3; return(oP); }
public static LowPolyMotion.Vector Cal_3DNormalVector(LowPolyMotion.xyz p1, LowPolyMotion.xyz p2, LowPolyMotion.xyz p3) // 计算空间面的法向量 { LowPolyMotion.Vector NV = new LowPolyMotion.Vector(0, 0, 0); LowPolyMotion.Vector tempV1 = new LowPolyMotion.Vector(0, 0, 0); LowPolyMotion.Vector tempV2 = new LowPolyMotion.Vector(0, 0, 0); tempV1 = Cal_3DGetVector(p1, p2); tempV2 = Cal_3DGetVector(p1, p3); NV.x = tempV1.y * tempV2.z - tempV1.z * tempV2.y; NV.y = -(tempV1.x * tempV2.z - tempV1.z * tempV2.x); NV.z = tempV1.x * tempV2.y - tempV1.y * tempV2.x; return(NV); }
private LowPolyMotion.xyz NewEndXYZ(int maxX, int maxY, int minZ, int maxZ) { LowPolyMotion.xyz result = new LowPolyMotion.xyz(rand.Next(0, maxX + 1), rand.Next(0, maxY + 1), rand.Next(0, maxZ + 1)); return(result); }
public static LowPolyMotion.Vector Cal_3DGetVector(LowPolyMotion.xyz p1, LowPolyMotion.xyz p2) // 求空间向量 { LowPolyMotion.xyz deltaXYZ = p2 - p1; LowPolyMotion.Vector v = new LowPolyMotion.Vector(deltaXYZ.x, deltaXYZ.y, deltaXYZ.z); return(v); }