예제 #1
0
        public void Calculate()
        {
            // texture orientation
            Real radangle   = MathUtil.BinaryAngleToRadian((ushort)TextureAngle);
            Real texorientx = (Real)System.Math.Cos(radangle);
            Real texorienty = (Real)System.Math.Sin(radangle);
            Real texorientz = 0;

            TextureOrientation = new V3(texorientx, texorienty, texorientz);

            // generate other endpoints from plane normal, texture origin, and texture
            //  orientation which determine the orientation of the texture's u v space
            //  in the 3d world's x, y, z space

            // plane normal
            V3 planeNormal = new V3(A, B, C);

            // first point
            // calculate z of texture origin from x, y, and plane equation
            Real z = (-A * X0 - B * Y0 - D) / C;

            P0 = new V3(X0, Y0, z);

            // cross normal with texture orientation to get vector perpendicular to texture
            //  orientation and normal = v axis direction
            V3 v2 = planeNormal.CrossProduct(TextureOrientation);

            v2.ScaleToLength(GeometryConstants.FINENESS);

            // cross normal with v axis direction vector to get vector perpendicular to v axis
            //  and normal = u axis direction vector
            V3 v1 = v2.CrossProduct(planeNormal);

            v1.ScaleToLength(GeometryConstants.FINENESS);

            // add vectors to origin to get endpoints
            P1 = P0 + v1;
            P2 = P0 + v2;
        }