/// <summary>
        /// Performs a UNION of two Fuzzy Sets
        /// </summary>
        /// <param name="fs1">Fuzzy Set 1</param>
        /// <param name="fs2">Fuzzy Set 2</param>
        /// <param name="colour">The colour to render the result</param>
        /// <returns>Result Set</returns>
        public static FuzzySet UnionFS(FuzzySet fs1, FuzzySet fs2, Brush colour)
        {
            FuzzySet result = new FuzzySet(); // just for error checking and returning

            //verify...
            if (fs1 == null || fs2 == null || fs1.Invalid() || fs2.Invalid())
            {
                result.SetErr(10);
                return result;
            }

            if (!RangeEqual(fs1, fs2))
            {
                result.SetErr(11); return result;
            }

            result = new FuzzySet(fs1);

            result.Clear();

            //lets get to work
            result.SetRange(fs1.GetLowRange(), fs1.GetHighRange());

            double x = 0, y = 0;
            double fs1x1, fs1x2, fs1y1, fs1y2;
            double fs2x3, fs2x4, fs2y3, fs2y4;
            double fs1s, fs1w, fs2s, fs2w;
            int i, k, rc;

            // traverse fs1 add all its points above fs2
            for (i = 0; i < fs1.GetNumPoints(); i++)
            {
                fs1w = fs1.GetWorldValue(i);
                fs1s = fs1.GetSetValue(i);
                fs2s = fs2.Fuzzify(fs1w);
                if (fs1s > fs2s || Operations.AEqual(fs1s, fs2s))
                {
                    result.AddPoint(fs1w, fs1s, false, false);
                }
            }

            // traverse fs2 add all its points above fs1
            for (i = 0; i < fs2.GetNumPoints(); i++)
            {
                fs2w = fs2.GetWorldValue(i);
                fs2s = fs2.GetSetValue(i);
                fs1s = fs1.Fuzzify(fs2w);
                if (fs2s > fs1s)
                {
                    result.AddPoint(fs2w, fs2s, false, false);
                }
            }

            // now traverse all line segments in fs1 testing for intersection with fs2
            for (i = 1; i < fs1.GetNumPoints(); i++)
            {
                fs1x1 = fs1.GetWorldValue(i - 1);
                fs1y1 = fs1.GetSetValue(i - 1);
                fs1x2 = fs1.GetWorldValue(i);
                fs1y2 = fs1.GetSetValue(i);
                for (k = 1; k < fs2.GetNumPoints(); k++)
                {
                    fs2x3 = fs2.GetWorldValue(k - 1);
                    fs2y3 = fs2.GetSetValue(k - 1);
                    fs2x4 = fs2.GetWorldValue(k);
                    fs2y4 = fs2.GetSetValue(k);

                    rc = Intersect(ref x, ref y,
                       fs1x1, fs1y1, fs1x2, fs1y2,
                       fs2x3, fs2y3, fs2x4, fs2y4);

                    if (rc == 0)
                    {
                        result.AddPoint(x, y, false, false);
                    }
                }
            }
            result.ColapseSet();

            result.LineColour = colour;

            return result;
        }