//空间两点的距离 public Double dexz(Pointz a, Pointz b) { double x = System.Math.Abs(b.x - a.x); double y = System.Math.Abs(b.y - a.y); double z = System.Math.Abs(b.z - a.z); return(Math.Sqrt(x * x + y * y + z * z)); }
private void 计算空间面积ToolStripMenuItem_Click(object sender, EventArgs e) { Pointz[] pointz = new Pointz[points.Length]; for (int i = 0; i < points.Length; i++) { pointz[i].x = points[i].X; pointz[i].y = points[i].Y; pointz[i].z = points[i].Z; } MessageBox.Show("" + area1.kongmianji(pointz)); }
//空间三角形的面积 public Double mianjiz(Pointz a, Pointz b, Pointz c) { double ab = dexz(a, b); double bc = dexz(b, c); double ac = dexz(a, c); if (ab + bc > ac & ab + ac > bc & ac + bc > ab) { double s = (ab + ac + bc) / 2; return(Math.Sqrt(s * (s - ab) * (s - ac) * (s - bc))); } else { return(0); } }