Example #1
0
        /// <summary>
        /// Populate the result collection with equivalent subdomains on curve B
        /// </summary>
        /// <param name="tA"></param>
        /// <param name="result"></param>
        private void MapAtoB(Interval tA, IList <Interval> result)
        {
            if (_SpanDomains == null)
            {
                return;
            }

            for (int iSpan = 0; iSpan < _SpanDomains.Count; iSpan++)
            {
                Interval spanDomain = _SpanDomains[iSpan];
                if (spanDomain.Overlaps(tA))
                {
                    var    overlap = spanDomain.Overlap(tA);
                    double tAStart = spanDomain.ParameterOf(overlap.Start);
                    double tBStart = CurveB.ParameterAt(iSpan, tAStart);
                    double tAEnd   = spanDomain.ParameterOf(overlap.End);
                    double tBEnd   = CurveB.ParameterAt(iSpan, tAEnd);
                    if (result.Count > 0 &&
                        result.Last().End == tBStart)
                    {
                        result[result.Count - 1] = result.Last().WithEnd(tBEnd);
                    }
                    else
                    {
                        result.Add(new Interval(tBStart, tBEnd));
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// Get the subdomain regions of curve B which have no stored relationship
        /// to any part of curve A - typically the new parts of the curve that were
        /// created by whatever operation generated the mapper.
        /// </summary>
        /// <returns></returns>
        public IList <Interval> UnrelatedPartsOfB()
        {
            var result = new List <Interval>();

            if (_SpanDomains == null)
            {
                return(result);
            }

            for (int iSpan = 0; iSpan < _SpanDomains.Count; iSpan++)
            {
                if (!_SpanDomains[iSpan].IsValid)
                {
                    double tBStart = CurveB.ParameterAt(iSpan, 0);
                    double tBEnd   = CurveB.ParameterAt(iSpan, 1);

                    if (result.Count > 0 &&
                        result.Last().End == tBStart)
                    {
                        result[result.Count - 1] = result.Last().WithEnd(tBEnd);
                    }
                    else
                    {
                        result.Add(new Interval(tBStart, tBEnd));
                    }
                }
            }

            return(result);
        }
Example #3
0
        /// <summary>
        /// Map from a parameter on curve A to an equivalent parameter
        /// on curve B.
        /// </summary>
        /// <param name="tA"></param>
        /// <returns></returns>
        public double MapAtoB(double tA)
        {
            if (_SpanDomains == null)
            {
                return(double.NaN);
            }

            for (int iSpan = 0; iSpan < _SpanDomains.Count; iSpan++)
            {
                Interval spanDomain = _SpanDomains[iSpan];
                if (spanDomain.Contains(tA))
                {
                    double tSpan = spanDomain.ParameterOf(tA);
                    return(CurveB.ParameterAt(iSpan, tSpan));
                }
            }
            return(double.NaN);
        }