예제 #1
0
        internal static Point3D Rotate(Point3D vertex, Axis axis, double angle)
        {
            //calculate offset values
            var xCenter = Math.Abs(screen.X / 2);
            var yCenter = Math.Abs(screen.Y / 2);
            var zCenter = Math.Abs(zDistanceMinMax.X - zDistanceMinMax.Y) / 2;

            //our distance vector - we need this?
            //double[] distanceVector = { xCenter, yCenter, zCenter };

            //base matrix representation of our vertex:
            double[,] baseVertexMtx = { { vertex.X, vertex.Y, vertex.Z, 1 } };

            //post rotation processed matrix
            double[,] rotatedMtx;

            switch (axis)
            {
            default:
            case Axis.X:
                rotatedMtx = MtxHelper.MtxMultiply(baseVertexMtx, RotateXMatrix(angle));
                break;

            case Axis.Y:
                rotatedMtx = MtxHelper.MtxMultiply(baseVertexMtx, RotateYMatrix(angle));
                break;

            case Axis.Z:
                rotatedMtx = MtxHelper.MtxMultiply(baseVertexMtx, RotateZMatrix(angle));
                break;
            }

            //return new rotated 3d point:
            return(new Point3D(rotatedMtx[0, 0], rotatedMtx[0, 1], rotatedMtx[0, 2]));
        }
예제 #2
0
        internal static Point3D Transition(Point3D vertex, Axis axis, double value)
        {
            //base matrix representation of our vertex:
            double[,] baseVertexMtx = { { vertex.X, vertex.Y, vertex.Z, 1 } };

            //post transition processed matrix:
            double[,] transitionedMtx = MtxHelper.MtxMultiply(baseVertexMtx, TransitioningMatrix(axis, value));

            //return new rotated 3d point:
            return(new Point3D(transitionedMtx[0, 0], transitionedMtx[0, 1], transitionedMtx[0, 2]));
        }
예제 #3
0
        //projections implementation:
        //orthographic:
        public static Point3D Orthographic(Point3D vertex)
        {
            //base matrix representation of our vertex:
            double[,] baseVertexMtx = { { vertex.X, vertex.Y, vertex.Z, 1 } };

            //orthographic matrix representation
            double[,] orthographicMtx =
            {
                { 1, 0, 0, 0 },
                { 0, 1, 0, 0 },
                { 0, 0, 1, 0 },
                { 0, 0, 0, 1 }
            };

            //resulted processed matrix
            double[,] processedMtx = MtxHelper.MtxMultiply(baseVertexMtx, orthographicMtx);

            return(new Point3D(processedMtx[0, 0], processedMtx[0, 1], processedMtx[0, 2]));
        }
예제 #4
0
        //perspective:
        public static Point3D Perspective(Point3D vertex)
        {
            //base matrix representation of our vertex:
            double[,] baseVertexMtx = { { vertex.X, vertex.Y, vertex.Z, 1 } };

            //calculate S(Z) as in formula
            var sZ = 1 / (1 + (vertex.Z / userPov.Z));

            //perspective matrix representation
            double[,] perspectiveMtx =
            {
                { sZ,  0, 0, 0 },
                {  0, sZ, 0, 0 },
                {  0,  0, 0, 0 },
                {  0,  0, 0, 1 }
            };

            //resulted processed matrix
            double[,] processedMtx = MtxHelper.MtxMultiply(baseVertexMtx, perspectiveMtx);
            return(new Point3D(processedMtx[0, 0], processedMtx[0, 1], processedMtx[0, 2]));
        }
예제 #5
0
        //oblique:
        public static Point3D Oblique(Point3D vertex, double angle = 90.0)
        {
            //base matrix representation of our vertex:
            double[,] baseVertexMtx = { { vertex.X, vertex.Y, vertex.Z, 1 } };

            //cos and sin angle calculation
            var cos = (Math.Cos(angle * (Math.PI / 180)));
            var sin = (Math.Sin(angle * (Math.PI / 180)));

            //oblique matrix representation (Cabinet)
            double[,] obliqueMtx =
            {
                {       1,       0, 0, 0 },
                {       0,       1, 0, 0 },
                { cos / 2, sin / 2, 1, 0 },
                {       0,       0, 0, 1 }
            };

            //resulted processed matrix
            double[,] processedMtx = MtxHelper.MtxMultiply(baseVertexMtx, obliqueMtx);
            return(new Point3D(processedMtx[0, 0], processedMtx[0, 1], processedMtx[0, 2]));
        }