Math3D.PlaneFrom3Points C# (CSharp) 메소드

PlaneFrom3Points() 공개 정적인 메소드

public static PlaneFrom3Points ( Vector3 &planeNormal, Vector3 &planePoint, Vector3 pointA, Vector3 pointB, Vector3 pointC ) : void
planeNormal Vector3
planePoint Vector3
pointA Vector3
pointB Vector3
pointC Vector3
리턴 void
    public static void PlaneFrom3Points(out Vector3 planeNormal, out Vector3 planePoint, Vector3 pointA, Vector3 pointB, Vector3 pointC)
    {
        planeNormal = Vector3.zero;
        planePoint = Vector3.zero;

        //Make two vectors from the 3 input points, originating from point A
        Vector3 AB = pointB - pointA;
        Vector3 AC = pointC - pointA;

        //Calculate the normal
        planeNormal = Vector3.Normalize(Vector3.Cross(AB, AC));

        //Get the points in the middle AB and AC
        Vector3 middleAB = pointA + (AB / 2.0f);
        Vector3 middleAC = pointA + (AC / 2.0f);

        //Get vectors from the middle of AB and AC to the point which is not on that line.
        Vector3 middleABtoC = pointC - middleAB;
        Vector3 middleACtoB = pointB - middleAC;

        //Calculate the intersection between the two lines. This will be the center
        //of the triangle defined by the 3 points.
        //We could use LineLineIntersection instead of ClosestPointsOnTwoLines but due to rounding errors
        //this sometimes doesn't work.
        Vector3 temp;
        ClosestPointsOnTwoLines(out planePoint, out temp, middleAB, middleABtoC, middleAC, middleACtoB);
    }