WithinEpsilon() private static méthode

private static WithinEpsilon ( float a, float b ) : bool
a float
b float
Résultat bool
Exemple #1
0
        public Vector3 Project(Vector3 source, Matrix projection, Matrix view, Matrix world)
        {
            Matrix  matrix  = Matrix.Multiply(Matrix.Multiply(world, view), projection);
            Vector3 vector3 = Vector3.Transform(source, matrix);
            float   a       = (float)((double)source.X * (double)matrix.M14 + (double)source.Y * (double)matrix.M24 + (double)source.Z * (double)matrix.M34) + matrix.M44;

            if (!Viewport.WithinEpsilon(a, 1f))
            {
                vector3 /= a;
            }
            vector3.X = (float)(((double)vector3.X + 1.0) * 0.5) * (float)this.Width + (float)this.X;
            vector3.Y = (float)((-(double)vector3.Y + 1.0) * 0.5) * (float)this.Height + (float)this.Y;
            vector3.Z = vector3.Z * (this.MaxDepth - this.MinDepth) + this.MinDepth;
            return(vector3);
        }
Exemple #2
0
        public Vector3 Unproject(Vector3 source, Matrix projection, Matrix view, Matrix world)
        {
            Matrix matrix = Matrix.Invert(Matrix.Multiply(Matrix.Multiply(world, view), projection));

            source.X = (float)(((double)source.X - (double)this.X) / (double)this.Width * 2.0 - 1.0);
            source.Y = (float)-(((double)source.Y - (double)this.Y) / (double)this.Height * 2.0 - 1.0);
            source.Z = (float)(((double)source.Z - (double)this.MinDepth) / ((double)this.MaxDepth - (double)this.MinDepth));
            Vector3 vector3 = Vector3.Transform(source, matrix);
            float   a       = (float)((double)source.X * (double)matrix.M14 + (double)source.Y * (double)matrix.M24 + (double)source.Z * (double)matrix.M34) + matrix.M44;

            if (!Viewport.WithinEpsilon(a, 1f))
            {
                vector3 /= a;
            }
            return(vector3);
        }