Ejemplo n.º 1
0
            public double GetRelativeError(List <Color> colors, List <double> accumulatedDistances)
            {
                GradientEyedropper.GradientInterval gradientInterval = this.Prev;
                if (gradientInterval == null)
                {
                    return(double.MaxValue);
                }
                bool     flag1     = this.R == colors.Count;
                bool     flag2     = gradientInterval.L == -1;
                double   num1      = accumulatedDistances[flag1 ? colors.Count - 1 : this.R];
                double   num2      = accumulatedDistances[flag2 ? 0 : gradientInterval.L];
                Vector3D vector3D1 = GradientEyedropper.Subtract(colors[flag2 ? this.L : gradientInterval.L], colors[this.L]);
                double   x1        = accumulatedDistances[this.L] - num2;
                Vector3D vector3D2 = GradientEyedropper.Subtract(colors[this.L], colors[flag1 ? this.L : this.R]);
                double   x2        = num1 - accumulatedDistances[this.L];

                if (flag2)
                {
                    return(Math.Max(2.0 * x1 * Math.Abs(vector3D2.X) + Math.Abs(Vector.CrossProduct(new Vector(0.0, vector3D2.X), new Vector(x2, vector3D2.X))), Math.Max(2.0 * x1 * Math.Abs(vector3D2.Y) + Math.Abs(Vector.CrossProduct(new Vector(0.0, vector3D2.Y), new Vector(x2, vector3D2.Y))), 2.0 * x1 * Math.Abs(vector3D2.Z) + Math.Abs(Vector.CrossProduct(new Vector(0.0, vector3D2.Z), new Vector(x2, vector3D2.Z))))));
                }
                if (flag1)
                {
                    return(Math.Max(2.0 * x2 * Math.Abs(vector3D1.X) + Math.Abs(Vector.CrossProduct(new Vector(0.0, vector3D1.X), new Vector(x1, vector3D1.X))), Math.Max(2.0 * x2 * Math.Abs(vector3D1.Y) + Math.Abs(Vector.CrossProduct(new Vector(0.0, vector3D1.Y), new Vector(x1, vector3D1.Y))), 2.0 * x2 * Math.Abs(vector3D1.Z) + Math.Abs(Vector.CrossProduct(new Vector(0.0, vector3D1.Z), new Vector(x1, vector3D1.Z))))));
                }
                return(Math.Max(Math.Abs(Vector.CrossProduct(new Vector(-x1, -vector3D1.X), new Vector(x2, vector3D2.X))), Math.Max(Math.Abs(Vector.CrossProduct(new Vector(-x1, -vector3D1.Y), new Vector(x2, vector3D2.Y))), Math.Abs(Vector.CrossProduct(new Vector(-x1, -vector3D1.Z), new Vector(x2, vector3D2.Z))))));
            }
Ejemplo n.º 2
0
            public double GetAbsoluteError(List <Color> colors, List <double> accumulatedDistances)
            {
                GradientEyedropper.GradientInterval gradientInterval = this.Prev;
                double   num1      = 0.0;
                bool     flag1     = this.R == colors.Count;
                bool     flag2     = gradientInterval.L == -1;
                Color    a1        = colors[flag2 ? this.R : gradientInterval.L];
                Color    b         = colors[flag1 ? gradientInterval.L : this.R];
                double   num2      = accumulatedDistances[flag1 ? colors.Count - 1 : this.R];
                double   num3      = accumulatedDistances[flag2 ? 0 : gradientInterval.L];
                double   num4      = num2 - num3;
                Vector3D vector3D1 = GradientEyedropper.Subtract(a1, b);

                for (int index = gradientInterval.L + 1; index < this.R; ++index)
                {
                    Vector3D vector3D2 = vector3D1 * ((accumulatedDistances[index] - num3) / num4);
                    Color    a2        = Color.FromArgb(byte.MaxValue, (byte)((double)a1.R + vector3D2.X), (byte)((double)a1.G + vector3D2.Y), (byte)((double)a1.B + vector3D2.Z));
                    num1 = Math.Max(num1, GradientEyedropper.Subtract(a2, colors[index]).LengthSquared);
                }
                return(Math.Sqrt(num1));
            }