예제 #1
0
        private void ComputeCircumcircleInfos()
        {
            _a = ExtMathf.Determinant3x3(P1.Pos, P2.Pos, P3.Pos)
                 - ExtMathf.Determinant3x3(P1.Pos, P2.Pos, P4.Pos)
                 + ExtMathf.Determinant3x3(P1.Pos, P3.Pos, P4.Pos)
                 - ExtMathf.Determinant3x3(P2.Pos, P3.Pos, P4.Pos);

            float n1 = P1.Pos.sqrMagnitude;
            float n2 = P2.Pos.sqrMagnitude;
            float n3 = P3.Pos.sqrMagnitude;
            float n4 = P4.Pos.sqrMagnitude;
            float Dx = ExtMathf.Determinant3x3(new Vector3(n1, P1.Y, P1.Z), new Vector3(n2, P2.Y, P2.Z), new Vector3(n3, P3.Y, P3.Z))
                       - ExtMathf.Determinant3x3(new Vector3(n1, P1.Y, P1.Z), new Vector3(n2, P2.Y, P2.Z), new Vector3(n4, P4.Y, P4.Z))
                       + ExtMathf.Determinant3x3(new Vector3(n1, P1.Y, P1.Z), new Vector3(n3, P3.Y, P3.Z), new Vector3(n4, P4.Y, P4.Z))
                       - ExtMathf.Determinant3x3(new Vector3(n2, P2.Y, P2.Z), new Vector3(n3, P3.Y, P3.Z), new Vector3(n4, P4.Y, P4.Z));

            float Dy = -(ExtMathf.Determinant3x3(new Vector3(n1, P1.X, P1.Z), new Vector3(n2, P2.X, P2.Z), new Vector3(n3, P3.X, P3.Z))
                         - ExtMathf.Determinant3x3(new Vector3(n1, P1.X, P1.Z), new Vector3(n2, P2.X, P2.Z), new Vector3(n4, P4.X, P4.Z))
                         + ExtMathf.Determinant3x3(new Vector3(n1, P1.X, P1.Z), new Vector3(n3, P3.X, P3.Z), new Vector3(n4, P4.X, P4.Z))
                         - ExtMathf.Determinant3x3(new Vector3(n2, P2.X, P2.Z), new Vector3(n3, P3.X, P3.Z), new Vector3(n4, P4.X, P4.Z)));

            float Dz = ExtMathf.Determinant3x3(new Vector3(n1, P1.X, P1.Y), new Vector3(n2, P2.X, P2.Y), new Vector3(n3, P3.X, P3.Y))
                       - ExtMathf.Determinant3x3(new Vector3(n1, P1.X, P1.Y), new Vector3(n2, P2.X, P2.Y), new Vector3(n4, P4.X, P4.Y))
                       + ExtMathf.Determinant3x3(new Vector3(n1, P1.X, P1.Y), new Vector3(n3, P3.X, P3.Y), new Vector3(n4, P4.X, P4.Y))
                       - ExtMathf.Determinant3x3(new Vector3(n2, P2.X, P2.Y), new Vector3(n3, P3.X, P3.Y), new Vector3(n4, P4.X, P4.Y));

            _d = new Vector3(Dx, Dy, Dz);

            _c = n1 * ExtMathf.Determinant3x3(P2.Pos, P3.Pos, P4.Pos)
                 - n2 * ExtMathf.Determinant3x3(P1.Pos, P3.Pos, P4.Pos)
                 + n3 * ExtMathf.Determinant3x3(P1.Pos, P2.Pos, P4.Pos)
                 - n4 * ExtMathf.Determinant3x3(P1.Pos, P2.Pos, P3.Pos);
        }